I was trying to validate an email address whenever user have entered one. I have tried with the below code, but it is not working:
function check(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);
}
}
Can anyone help me how I can able to solve this issue?