Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    New Coder
    Join Date
    Oct 2009
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    You could do

    <input type = "text" id = "fullName" onblur = "validate(this)">
    My input tags look like this per my book:
    <input type="text" id="custEmail" name="custEmail" onblur="validate(this);">

    Is having both name and id in there messing it up?

  2. #17
    New Coder
    Join Date
    Oct 2009
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    My brain's getting fried! lol I may have to submit what I have with questions to my instructor and hope he gets back to me in time to get it figured out and turned in on time on Sunday. Seems like plenty of time, but for some reason online instructors aren't "online" much!

  3. #18
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,898
    Thanks
    203
    Thanked 2,530 Times in 2,508 Posts
    Quote Originally Posted by chelseasikoebs View Post
    Oh. Wow. I got that straight from the w3schools.com site!
    You should be aware that the w3schools site is now very much out of date. As felgall says, it teaches 20th century Javascript.

    Code:
    <input type="text" id="custName" name="custName" onblur="validateName(this);">
    
    <script type = "text/javascript">
    
    function validateName (which) {
    var val = which.value;
    val = val.replace(/[^a-z\s\-]gi, "");  // strip all but letters (ignore case) and hyphens and spaces - Mary-Lou Smith
    which.value = val;  // write it back to the field
    if (val.length < 4) {
    alert ("Your name must have at least 4 alpha characters");
    which.focus();  // refocus on the incorrect field so compelling the user to make a valid entry
    return false;
    }
    }
    </script>
    Last edited by Philip M; 12-05-2012 at 09:03 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


 
Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •