Validate Email using Regular Expression In JavaScript-
1. Create Input type Text box and and onclick cal checkemail function of Javascriptusing .
2. Define Function in Script with regex expression .
<script>
function checkEmail()
{
email = $('#txtEmail');
filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(email.value)) {
// valid Email
return true;
}
else
{return false;}
}
</script>
<body>
<input id="txtEmail" type="text" onclick="checkEmail();" />
</body>
0 comments :
Post a Comment