aspx Tutorial

NET Articles,jQuery demo, asp.net with jQuery, online tutorial,Jquery, SilverLight, Javascript, asp.net,JSON, MVC,.NET Articles,demo, Web Services,
Advertise Here

Toolbar

Get our toolbar!

Advertize



Posted by Aamir Hasan   on Friday, January 7, 2011 Total Views:  

I was recently asked a question, that how to validate email address using jQuery in asp.net web site. jQuery validation Plugin is best choice for validation.

Here's an example

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
   <title>Validation of Email address using jQuery in asp.net</title>
   <style type="text/css">
       #field
       {
           margin-left: .5em;
           float: left;
       }
       #field, label
       {
           float: left;
           font-family: Arial, Helvetica, sans-serif;
           font-size: small;
       }
       br
       {
           clear: both;
       }
       .mend
       {
           color: Red;
       }
       
       label.error
       {
           color: Red;
           padding-left: 16px;
           margin-left: .3em;
       }
       label.valid
       {
           display: block;
           width: 16px;
           height: 16px;
       }
   </style>
   <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
   <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
   <script type="text/javascript">
       jQuery.validator.setDefaults({
           debug: true,
           success: "valid"
       }); ;
   </script>
   <script>
       $(document).ready(function () {
           $("#form1").validate({
               rules: {
                   field: {
                       required: true,
                       email: true
                   }
               }
           });
       });
   </script>
</head>
<body>
   <form id="form1" runat="server">
   <div>
       <label for="field">
           Email Address:<span id="star" class="mend"> *</span>
       </label>
       &nbsp;<input class="left" id="field" name="field" />
       <br />
       <br />
       <input type="submit" value="Submit" /></div>
   </form>
</body>
</html>

Output

 

Download

EmailAddress.zip (3.61 kb)


See Live Demo

Protected by Copyscape Online Plagiarism Tool

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5