Validating an Email Address

This function uses a regular expression to validate an email address and ensure it is in the correct format using strict rules to verify the length of the domain suffix, position of the @ symbol and valid characters etc. If the email address is valid it returns true, otherwise it returns false.

function isEmailAddress(s) { var objRegExp = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z] {2,4})$/ return objRegExp.test(s); }