jquery - validate characters on keypress?

前端 未结 7 1387
既然无缘
既然无缘 2020-12-05 10:25

I have a form text field that I want to allow only numbers and letters in. (i.e., no #$!, etc...) Is there a way to throw up an error and prevent the keypress from actuall

7条回答
  •  感动是毒
    2020-12-05 10:58

    The above jquery extension (ForceAlphaNumericOnly) is good but still allows the following characters through !@#$%^&*()

    On my Mac, when you press the shift key (keycode 16) and then 1, it enters ! but the keycode is 49, the keycode for 1.

提交回复
热议问题