Would someone mind helping me correct this code?
function regExpression(stringValue) {
if (stringValue === null || stringValue.length === 0) {
alert("No string was entered"); }
else if (stringValue.match(/^[_.-a-z0-9]+@[_.-a-z]+\\.[a-z]{2,4}$/i) != null)
alert("This is a valid email.");
else {
alert("The string is not a valid email."); }
}
The problem is that:
john.smith@gmail123.com
works. The 123 in the provider shouldn’t be allowed, but it is. I’m trying to build a regular expressions for email.