javascript email format validation

A

Anonymous

Guest
I just can not seem to find a javascript code that checks if the format is correct. I know that someone could enter an bogus email address but thats ok. I am just after checking if the format of the email entered looks correct before the form is submitted.
Please can I have some suggestions of what others have used.

It could be that I am doing this wrong...

if (/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(email.value.lrtrim())) {
errorMessage = 'Email contains invalid character/s';
 
Back
Top