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:

  1. A client side jQuery validator for all input boxes
  2. ASP .NET problem when using AJAX with jQuery Solution
  3. Check all CheckBoxes using CLASS group (ASP .NET & jQuery)
  4. Run C++ .NET Programs without the need of .NET framework
  5. Snipping Tool of windows 7 for windows XP finally!

 

Comments are closed.

blog comments powered by Disqus
  • RSS
  • Twitter
  • Facebook
  • Flickr
  • DeviantArt
  • YouTube