Introduction : -
Here I will explain how to allow only numbers or numeric characters in textbox using JQuery in asp.net.with error message
Description :-
In previous posts I explained I have Explain create simple drop down menu using jquery ,Simple Menu using Jquery step by step Now I will expplain how to allow only numbers or numeric characters in textbox using JQuery in asp.net.
Code is Here
<head runat="server">
<title>jquery text box valiation only enter the number</title>
<script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript">
$(document).ready(function () {
//called when key is pressed in textbox
$("#quantity").keypress(function (e) {
//if the letter is not digit then display error and don't type anything
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
//display error message
$("#errmsg").html("Digits Only").show().fadeOut("slow");
return false;
}
});
});
</script>
<style type="text/css">
#errmsg
{
color:Red;
</style>
</head>
Here I will explain how to allow only numbers or numeric characters in textbox using JQuery in asp.net.with error message
Description :-
In previous posts I explained I have Explain create simple drop down menu using jquery ,Simple Menu using Jquery step by step Now I will expplain how to allow only numbers or numeric characters in textbox using JQuery in asp.net.
To restrict user to enter only number in textbox we write the following code as shown below
Jquery code as shown below
<head runat="server">
<title>jquery text box valiation only enter the number</title>
<script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript">
$(document).ready(function () {
//called when key is pressed in textbox
$("#quantity").keypress(function (e) {
//if the letter is not digit then display error and don't type anything
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
//display error message
$("#errmsg").html("Digits Only").show().fadeOut("slow");
return false;
}
});
});
</script>
<style type="text/css">
#errmsg
{
color:Red;
</style>
</head>
asp.net form code here
Code is Here
<body>
<form id="form1" runat="server">
<div>
Number : <input type="text" name="quantity" id="quantity" /> <span id="errmsg"></span><br /><br/>
</div>
</form>
</body>
After Write Code The Page Is Shown Below
Simple Menu using Jquery Beginners Tutorial , create simple drop down menu using jquery
Code is Here
<body>
<form id="form1" runat="server">
<div>
Number : <input type="text" name="quantity" id="quantity" /> <span id="errmsg"></span><br /><br/>
</div>
</form>
</body>
After Write Code The Page Is Shown Below
Download sample code attached
Simple Menu using Jquery Beginners Tutorial , create simple drop down menu using jquery
No comments:
Post a Comment