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 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2006
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with this e-mail validation function

    I am missing something because when an e-mail passes validation, I cannot go to the next field, it justs focuses on that field and selects it? What am I doing wrong?

    function checkEmail(field, fieldname){
    var x = field.value;
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if(field.value.length > 0 ) {
    if (filter.test(x));
    else alert('Oops! This doesn\'t appear to be a valid e-mail address.');
    field.focus();
    field.select();
    }
    }

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,733
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    function checkEmail(field, fieldname){
    var x = field.value;
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if(field.value.length > 0 ) {
    if (filter.test(x)) {
    return true;
    }
    else {
    alert('Oops! This doesn\'t appear to be a valid e-mail address.');
    field.focus();
    field.select();
    return false;
    }
    }


  •  

    Posting Permissions

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