JQuery Validation need For this

Posted by Jayakumars under ASP.NET AJAX on 9/5/2013 | Points: 10 | Views : 2272 | Status : [Member] [MVP] | Replies : 3
Hi

I need JQuery Numeric only validation

After page post did not work my JQuery then Jquery did not work in Update panel

How to validate numeric only jquery

Mark as Answer if its helpful to you


Responses

Posted by: Learningtorise on: 9/5/2013 [Member] Starter | Points: 25

Up
0
Down
Add this javascript function

 function isNumberOnly(evt) {

var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;

return true;
}


Add following event to your textbox or input control:

onkeypress="return isNumberOnly(event)"


You're done. PS: it wont take "." OR Period(.) also. But u can always edit function to suit your need.



http://hashtagakash.wordpress.com/

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/5/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer these links
http://dotnetnukes.blogspot.in/2013/04/jquery-restrict-to-allow-only-numbers.html
http://stackoverflow.com/questions/891696/jquery-what-is-the-best-way-to-restrict-number-only-input-for-textboxes-all?lq=1
http://www.aspdotnet-suresh.com/2013/04/jquery-allow-only-numbers-in-textbox.html
http://stackoverflow.com/questions/995183/how-to-allow-only-numeric-0-9-in-html-inputbox-using-jquery

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 9/5/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
You can use the below code:-

$(document).ready(function() {
$("#txtboxToFilter").keydown(function(event) {
// Allow: backspace, delete, tab, escape, and enter
if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 ||
// Allow: Ctrl+A
(event.keyCode == 65 && event.ctrlKey === true) ||
// Allow: home, end, left, right
(event.keyCode >= 35 && event.keyCode <= 39)) {
// let it happen, don't do anything
return;
}
else {
// Ensure that it is a number and stop the keypress
if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) {
event.preventDefault();
}
}
});
});

Happy Coding.

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response