Hi,
I have the following e-mail validation code:
It works fine but it does not validate ".con" as incorrect for ".com"
So, I found this regular expression which does validate for .com, .gov etc.:
However, if I simply replace the regular expressions in the first code sample with the second code sample, the first code sample breaks.
My question is how can I incorporate the extension checking capability of the second sample in to the first code sample?
Thanks much!
I have the following e-mail validation code:
Code:
fValidate.prototype.email = function( level )
{
if ( this.typeMismatch( 'text' ) ) return;
if ( typeof level == 'undefined' ) level = 0;
var emailPatterns = [
/.+@.+\..+$/i,
/^\w.+@\w.+\.[a-z]+$/i,
/^\w[-_a-z~.]+@\w[-_a-z~.]+\.[a-z]{2}[a-z]*$/i,
/^\w[\w\d]+(\.[\w\d]+)*@\w[\w\d]+(\.[\w\d]+)*\.[a-z]{2,7}$/i,
];
if ( ! emailPatterns[level].test( this.elem.value ) )
{
this.throwError();
}
}
It works fine but it does not validate ".con" as incorrect for ".com"
So, I found this regular expression which does validate for .com, .gov etc.:
Code:
/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi
My question is how can I incorporate the extension checking capability of the second sample in to the first code sample?
Thanks much!