Hi. added a email valdation check to my webpage. but for some reason it always says the email is invalid. please help
Code:
function checkEmail() {
var email = document.mail.email;
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email.value)) {
alert('Please provide a valid email address');
email.focus;
return false;
}
else return true
}
ive just set up a new page with just that script and it works fine, it must be something else in the script ive messed up. thanks for helping
ah okie. probably a rogue { or } somewhere.
you cna do several things. use jsbeautifier.org on your script ( alos helps find unclosed brackets etc.., or load your test page in firefox with firebug installed to check for possible console errors
you cna do several things. use jsbeautifier.org on your script ( alos helps find unclosed brackets etc.., or load your test page in firefox with firebug installed to check for possible console errors
you could also try jslint online or jshint.org
I have tried EVERYTHING and i still cannot get this damn thing to work, any more ideas ?
you cna do several things. use jsbeautifier.org on your script ( alos helps find unclosed brackets etc.., or load your test page in firefox with firebug installed to check for possible console errors
you could also try jslint online or jshint.org
nevermind, im being stupid!. I had to input id's as email, which obviously broke the code
I have just tried this script but my "name" for my email input is emailAD so which parts of the following do I change from email to emailAD because I don't think it is all of them, is it:
Code:
function checkEmail() {
var email = document.mail.email;
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email.value)) {
alert('Please provide a valid email address');
email.focus;
return false;
}
else return true
}
I have just tried this script but my "name" for my email input is emailAD so which parts of the following do I change from email to emailAD because I don't think it is all of them, is it:
Code:
function checkEmail() {
var email = document.mail.email;
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email.value)) {
alert('Please provide a valid email address');
email.focus;
return false;
}
else return true
}
Change the bit in bold, to document.getElementById('emailAD')
Bookmarks