EMail Validation using JQuery with Regular Expression | How to do EMail validation using JQuery

We can do email validation using JQuery. Please check below code. Here i have using regular Expression for doing email validation.

For more validations, please go through this Form Validations

Output:

EMail VAlidation using JQuery in ASP.NET
EMail VAlidation using JQuery with RegularExpression 

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <title></title>
    <script type="text/javascript">
        $(document).ready(function() {
            $('#btnSubmit').click(function() {
                var inputEmail = $("#txtEmail").val();
                var emailRegularExpression = /^(^([0-9a-zA-Z]+([_.-]?[0-9a-zA-Z]+)*)@[0-9a-zA-Z]+([_.-]?[0-9a-zA-Z])*\.[a-zA-Z]{2,4})+$/;

                if (!emailRegularExpression.test(inputEmail)) {
                    $('#ErrorMessage').html('Invalid Email Address');
                }
            });
        });
    </script>

</head>
<body>
    <input type="text" id="txtEmail" />
    <input type="submit" id="btnSubmit" />
<div id='ErrorMessage' style="color:red;"></div>
</body>
</html>

Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar