I want to varify if the entered string is in email format or not. I am bit confused. I tried to write below code but failed. Can ayone help me please.
Javascript Code:
<script>
function emailValidation(id)
{
var emailPattern = var emailPattern = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if (emailPattern.test(id) === false)
{
alert("not a valid email address.");
}
document.getElementById(id).value = "";
}
</script>
HTML Code:
<input type="text" id="empemail" onblur="emailValidation('empemail')" name="email" placeholder="eg: aaa@abc.ca" required="">