I had a page full of dynamically created textboxes for my gridview (using ASP templates of course). see the above image to get what I mean.

All text boxes have to accept only numerical values. So how you can do that with a simple code?

$(document).ready(function(){
$(":input").keydown(function(event){
//alert(event.keyCode);
if((event.keyCode < 47 || event.keyCode > 58) && (event.keyCode < 95 || event.keyCode > 106) &&
(event.keyCode != 8 && event.keyCode != 13 && event.keyCode != 110
&& event.keyCode != 46 && event.keyCode != 190 ))return false;
});
});

Don’t forget to save the code as JS file and include it in your HTML / ASP / PHP page!
and ofcourse include the jQuery library before it.

enjoy coding ;-)


Related posts:

  1. A simple jQuery validator function for an ASP .NET input TextBox
  2. ASP .NET problem when using AJAX with jQuery Solution
  3. Check all CheckBoxes using CLASS group (ASP .NET & jQuery)
  4. Fotobook + Facebook Connect, the incompatibility fix

Comments are closed.

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