dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersAbul Bashar Sardar
Shine S
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Resources » Code Snippets » jQuery

How to validate email address using jQuery


Posted Date:     Category: jQuery    
Author: Member Level: Gold    Points: 15


In this article I'm going to explain how to validate the email address using jQuery.



 



In this article I'm going to explain how to validate the email address using jQuery.
To validate the email address, I have created a separate function to check whether email id is valid or not.
Email Validation is done using Regualr expression.




<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" src="jquery-1.2.6.js"></script>

<script type="text/javascript">
$(document).ready(function() {
$('#Button1').click(function() {
var vtxtEmail = $('#txtEmailID').val();
if ($.trim(vtxtEmail).length == 0) {
alert('Plz enter valid email address!');
e.preventDefault();
}
if (TovalidateEmail(vtxtEmail)) {
alert('This is not valid email id');
}
else {
alert('Invalid Email Address');
e.preventDefault();
}
});
});


function TovalidateEmail(vtxtEmail) {
var filterexpression = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (filterexpression.test(vtxtEmail)) {
return true;
}
else {
return false;
}
}?
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtEmailID" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
</body>
</html>





Did you like this resource? Share it with your friends and show your love!


Responses to "How to validate email address using jQuery"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: How to show simple popup window using jQuery
    Previous Resource: How to manipulate dropdownlist using jQuery
    Return to Resources
    Post New Resource
    Category: jQuery


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    How to validate email address using jQuery  .  



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.