this perfectly works :
var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
var email = 'nobody.foo.bar@gmail.com';
if (email.search(emailRegEx) == -1)
{
alert('You must enter a valid e-mail address');
}
give me a minute i will go make the triming
Here, a very stupid demo of the space trimming regex, if you quit that regex, you will find out that the spaces makes your regex not to work, still, it might be other chars interfering
var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
// the spaced email
var email = ' nobody.foo.bar@gmail.com ';
alert( "<"+email+">" );
email = email.replace( /(^[\s ]{1,}|[\s ]{1,}$)/g , "" ) ;
// the unspaced email :D
alert( "<"+email+">" );
if (email.search(emailRegEx) == -1)
{
alert('You must enter a valid e-mail address');
}
check it up, and then, if it does not work just post the whole html, maybe i can find what is going wrong there