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.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2003
    Location
    L.A.
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JScript Validation (alpha only)

    i am trying to make sure a user posts only valid information. the first and last name fields are giving me trouble. i need to have a script that will validate for <b>no numerical characters</b> in the whole variable using the <b>onblur</b> method. i cannot get this accomplished without getting mulitle errors. what i have is not working in other words.

    if anyone has seen it on a site or knows how to validate for it please let me know. thanks in advance!

  • #2
    New to the CF scene
    Join Date
    Jun 2003
    Location
    L.A.
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    the actual file!

    don't get confused. an asp file can use javascript in there.
    Attached Files Attached Files

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    This checks for bad characters and also that the name is "sensible".

    function checkname(which) {
    var badchars='/\@:?%!&$#~<>^*+=";1234567890{}[]'; // invalid characters
    var vowels="AaEeIiOoUuYy"; // name must contain at least one vowel: M.H.Byng ok!
    var cons=/[^AaEeIiOoUuYy]/; // name must contain at least one consonant: A.A.Lee ok!
    var blank="";
    var vflag=0;
    var bflag=0;
    var name=which.value;
    for (x=0;x < name.length;x++) {
    if (vowels.indexOf(name.charAt(x))!=-1) {vflag=1}
    if (badchars.indexOf(name.charAt(x))!=-1) {bflag=1}
    }
    if (name.search(cons)==-1) {vflag=0}
    if (name.length < 6 || name.length > 24 || vflag==0) {
    alert ("That does not appear to be a valid person's name. \nPlease try again.");
    which.value=blank;
    which.focus();
    }
    if (bflag==1 && vflag==1) {
    alert ("Invalid characters were entered into this field.\nOnly alphabetic characters are allowed.\n\nPlease try again.");
    which.value=blank;
    which.focus();
    }
    }


  •  

    Posting Permissions

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