Allow only certain characters

前端 未结 2 663
孤街浪徒
孤街浪徒 2021-01-20 22:26

I\'d like to block all characters from being inputed except 0-9,a-z,A-Z range only alphanumeric characters. So when someone types ! for examplee nothing is written into inp

相关标签:
2条回答
  • 2021-01-20 22:42

    You need to write a function that listens for the onkeypress event for the form field, then check to see if the form contains any unwanted characters, and if it does, you update the field with those characters removed.

    0 讨论(0)
  • 2021-01-20 22:42

    Or maybe you can use Alphanumeric Plugin for jQuery :

    $('#yourInput').alphanum();
    
    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题