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
TextBox ID & Class Call To TextBox
Next - Run [F5] The Program - Only Allowed Numeric & 10 Digit's 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
This is very helpful tutorial, i also wrote tutorial about it. Hope you like it. https://htmlcssphptutorial.wordpress.com/2015/09/14/insert-only-numbers-using-jquery/
ReplyDeleteThis is very easy
ReplyDelete