TextBox Allows Only Numeric Values And Accept 10 Digits Only Using JQuery in Asp.Net C#

TextBox Allows Only Numeric Values And Accept 10 Digits Only

If Entered TextBox Values  Only Enter Numeric Values Charcter Not Enter (Accepted) And  Only 10 Digit's  Allowed for Mobile Number  Using JQuery in Asp.Net  C#.

                            Download Coding

                                                Download

                                     DEMO





                         HTML CODING



<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>

<script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>

<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>

<script lang ="javascript" >
    $(document).ready(function () {
        $('.txtMobileNumber').live('keydown', function (e) {

            if (parseInt(e.keyCode) > 47 && parseInt(e.keyCode) < 58) {

                if (parseInt($(this).val().length) <= 10) {

                }
                else {

                    e.preventDefault();
                }
            }
            else {

                e.preventDefault();
            }
        });
    });
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
   
    <asp:Label ID="Label1" runat="server" ForeColor="#CC3300" Text="Mobile Number"></asp:Label>
      <asp:TextBox ID="txtMobileNumber" class="txtMobileNumber"
       
         runat="server" Height="20px" Width="130px"></asp:TextBox>
    <br />
    <br />
</div>
</form>
</body>

</html>



First - Add  New Web Form  -  Select TextBox From  ToolBox






Next  - Add The JQuery Plugins - Solution Explorer 
& Coding







TextBox  ID & Class Call To TextBox








Next - Run [F5] The Program - Only Allowed Numeric & 10 Digit's Only









2 comments: