I am trying to add a bit of JavaScript validation to my application to check that an email address is formatted correctly.
This is the code that I am using to perform the validation checks:
var bValid = true;
allFields.removeClass( "ui-state-error" );
bValid = bValid && checkLength( email, "email", 6, 80 );
bValid = bValid && checkLength( password, "password", 5, 16 );
bValid = bValid && checkRegexp( name, /^[a-z]([0-9a-z_])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
var reg = /^(([^<>()[]\.,;:s@"]+(.[^<>()[]\.,;:s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/;
bValid = bValid && checkRegexp(email, reg, "eg. smith@hotmail.com");
bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );
if ( bValid ) {
//DO ajax call
$( this ).dialog( "close" );
}
And I am getting this error:
I have tried numerous examples of regex expressions but all get caught by the parser.