For one of my requirement, I need to restrict/disable end-user to enter
space in the input field or textbox. This was piece of cake with jQuery.
All I need to do is to check the keycode of spacebar and restrict its
default action on keydown event. See below jQuery code. "txtNoSpaces" is
the name of the textbox.
1 | $(document).ready(function(){ |
2 | $("#txtNoSpaces").keydown(function(event) { |
3 | if (event.keyCode == 32) { |
4 | event.preventDefault(); |
5 | } |
6 | }); |
7 | }); |
No comments:
Post a Comment