Description:
To validate email address on
client side, we can use JavaScript and Jquery.
We have to use regular expression
patterns for validating email address. Regular expression will check to make
sure that the entered text is a valid email address.
Here, I am using a function which
will take value of the email address as parameter and it will test with the
regular expression defined in the function.
If the email address matches with
the regular expression, function will return true. If it is not valid, function
will return false.
The result is displayed to the
user via alert box.
Example program:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script
type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script
type="text/javascript">
$(document).ready(function () {
$("#Button1").click(function () {
if
(IsvalidEmail($("#TextBox1").val()))
{
alert("Valid Email Address.");
}
else
{
alert("InValid Email Address.");
}
});
function
IsvalidEmail(args) {
var obj =
/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
return
obj.test(args);
};
});
</script>
</head>
<body>
<form
id="form1"
runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
</body>
</html>
Email validation using Jquery , Jquery Regex
validation for Email address using Jquery , Regular Expression to validate
Email address using Jquery, Check valid Email addresses using Jquery.
Email address validation with Jquery
0 comments:
Post a Comment