![jquery-logo[1]](http://www.addaxsoft.com/images/jquery-logo1-150x150.png)
Having this scenario: You have an input ASP .NET TextBox that you want only number (or only charters) to be in it, and you want your code to be light (meaning: cliently executed).
Here what I have done to filter any other input than number for my ASP .NET textBox.
jQuery:
$(document).ready(function(){
$(document).keydown(function(event){
//alert(event.keyCode)
if((event.keyCode < 47 || event.keyCode > 58) && (event.keyCode != 8 && event.keyCode != 13))return false;
});
});
ASP .NET
explnation:
for the jQuery we put $(document).keydown because if you put a tag to your textbox (meaing: “#TextBox2″) then it wont work. Try it yourself!
good luck coding.
Related posts:
