Loading ...

How to validate minimum length in textbox by jquery | CodeAsp.Net

How to validate minimum length in textbox by jquery

 /5
0 (0votes)

In this blog we will see how we can validate the minimum length of textbox.

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">
 <title>Validate Textbox</title>
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>  

</head>
<body >
    <form id="form1" runat="server">
        <asp:TextBox ID="txtValidate" runat="server" TextMode="MultiLine"></asp:TextBox>
        <span  id="txtBox_warning" style="color:red"></span > 
    </form>
</body>

  <script type="text/javascript" language="javascript">
        
    $(document).ready(function()
    {
        var txtValue = $('#<%= txtValidate.ClientID %>');
        $(txtValue).blur(function() 
        {
          $("#txtBox_warning").empty(); 
 
          if (txtValue.val().length < 10) 
            $("#txtBox_warning").append("Minimum 10 Characters are required");
            
        });
    });
    
    </script>
</html>


Comments (no comments yet)

Top Posts