I have a requirement to validate an email address entered when a user comes out from the textbox.
I have googled for this but I got form validation JScript; I don’t want form validation. I want textbox validation.
I have written below JScript but “if email invalid it’s not returning the same page”.
function validate(email) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
//var address = document.getElementById[email].value;
if (reg.test(email) == false)
{
alert('Invalid Email Address');
return (false);
}
}
Assuming your regular expression is correct:
inside your script tags
in your textfield: