I have the following but the validation isn't working any ideas? I basically want it to validate the email and then validate the confirm email address. The confirm email address should match the email address input. Thanks.
PS.. looking at it, since the error message is not being displayed in an alert box, replace all instances of "\n" with "<br />".
PPS.. also, all this does is check for SOMETHING in the fields. If you want to make sure that the email address is in a particular format (user@domain.com), then we can use Regular Expressions for a mask.
Thanks Wolfshade, I corrected the javascript and it now works. I would like to apply regular expressions but I am unsure about the syntax. Please could you provide an example...such as the email field:
I sent you a PM with some RegEx masks for validation.
For email validation, I usually do the following:
Code:
...
if(df.emailTo.value.length < 6) {
warn += "Please enter a valid TO: email address.\n"; }
else {
if(!checkEmail(df.emailTo.value)) { // Exclamation mark means 'not', 'false', or just plain 'didnt'
warn += "Please make sure TO: email address is valid.\n"; }
}
...
And then I'll have another function for checking the format:
Code:
function checkEmail(inputvalue){
var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
if(pattern.test(inputvalue)){
return true;
}else{
return false;
}
}
Bookmarks