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:

