Forum Moderators: open
I already have a email regular expression.
The code I though would work is this:
if(!email == "" ¦¦ !email.match(email.RegExp)) {
alert ("alert message here");
return false;
{
and so on...
I have already set a variable for "email" etc. I just can't get the bit to work for it either being blank or matching the regular expression!
have you tried printing out the length of the email value and/or the email value itself (between delimiters) to insure there are no "extra" characters?
if(!((email == "" )¦¦(email.match(email.RegExp))))
rather than
if(!email == "" ¦¦ !email.match(email.RegExp))
not ( A or B ) is different from ( not A ) or ( not B ) demoran theory
Better still is to avoid mixing OR's and NOT's
if ( (email == "" ) ¦¦ (email.match(email.RegExp)) ) {
// ok code if any
} else {
alert ("alert message here");
return false;
}