Jquery filter text boxes (Preventing user from inserting certain characters)

后端 未结 3 696
余生分开走
余生分开走 2021-01-23 16:30

I am trying to prevent users from typing certain characters in text boxes and this is the code that I have so far :

$().ready(function() {
  $(\".textbox\").keyp         


        
3条回答
  •  醉话见心
    2021-01-23 17:27

    When I've had to do things like this, I've used the event onkeyup.

    Instead of stripping out the chars automatically (which may lead to user confusion), why not have a regex that checks for valid chars on key up, and then maybe displays a side note to the input, something like 'You may not enter numbers in this field', or something more specific to the actual input field, 'Your city name may not include number(s).'.

提交回复
热议问题