I want to validate an email with a regex. And the code following shows the regular expression that I've used. The form however does not accept a simple anystring@anystring.anystring. (anystring is an alphabetic).
Am I missing out something?
window.onload = function () {
document.getElementById("form").onsubmit = validate;
}
function validate() {
var email = document.getElementsByTagName("input")[6].value;
var regex = /^\w@\w+\.\w$/;
if (!regex.test(email)) {
alert("enter a valid email");
return false;
} else return true;
}