...

View Full Version : Help with this e-mail validation function



binici
05-25-2006, 06:46 PM
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();
}
}

Philip M
05-26-2006, 07:36 AM
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;
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum