Email ID Validation Using JavaScript Regular Expression
Source Code :
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Email ID Validation Using JavaScript Regular Expression.</title>
<script language="javascript">
functionValidateEmailID(txtEmailID) {
varfilter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if(txtEmailID.value == "") {
txtEmailID.style.border = "";
returntrue;
}
elseif (filter.test(txtEmailID.value)) {
txtEmailID.style.border = "";
returntrue;
}
else{
txtEmailID.style.borderColor = "red";
returnfalse;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
Enter Email ID :
<input type="text" onkeyup="ValidateEmailID(this);" />
</div>
</form>
</body>
</html>
Comments
Post a Comment