Cannot be blank
<Input onblur = "if (this. value. replace (/^ + | + $/g,'') = '') alert ('cannot be blank! ') ">
Only English and numbers can be entered.
<Input onblur = "if (/[^ 0-9a-zA-Z]/g. test (value) alert ('error')">
<Input onkeyup = "value = value. replace (/[^ 0-9a-zA-Z]/g,'') "/>
<Input type = "text" onkeyup = "value = value. replace (/[^ \ a-\ z \ A-\ Z0-9]/g,'') ">
A judgment character consists of letters, numbers, underscores, and periods. It must start with an underscore or letter.
/^ ([A-zA-z _] {1}) ([\ w] *) $/g. test (str)
Only numbers can be entered
<Input name = "text" type = "text" id = "NewPage" onKeyUp = "value = value. replace (/\ D/g, '')" onafterpaste = "value = value. replace (/\ D/g, '')">
Only Chinese characters can be entered
<Input type = "text" onkeyup = "value = value. replace (/[^ \ u4E00-\ u9FA5]/g,'') ">
Only English can be entered
<Input type = "text" onkeyup = "value = value. replace (/[^ \ a-\ z \ A-\ Z]/g,'') ">
<Input type = "text" onkeyup = "value = value. replace (/[^ a-zA-Z]/g,'') ">
Only Chinese characters, English letters, numbers, @ symbols, and. symbols can be entered.
<Input type = "text" onkeyup = "value = value. replace (/[^ \ a-\ z \ A-\ Z0-9 \ u4E00-\ u9FA5 \ @ \.] /g, '')">
You can only enter English letters, and the paste menu cannot be displayed.
<Input type = "text" onkeyup = "value = value. replace (/[^ \ a-\ z \ A-\ Z]/g, '')" onkeydown = "fncKeyStop (event) "onpaste =" return false "oncontextmenu =" return false "/>
Only numbers and periods (Note::D In [^ \ d \.] cannot be written as uppercase D, otherwise it becomes all characters except numbers)
<Input name = "price" type = "text" size = "8" maxlength = "8" onkeyup = "value = value. replace (/[^ \ d \.] /g, '')">
All in all: Enter onkeyup = "value = value in <input>. replace (/[^ \ X]/g, '')" and then in (/[\ X]/g ,'') replace X in with the code you want to enter.
Chinese: U4E00-u9FA5
Number: D, 0-9
English: A-z, A-Z
Other symbols @, point, or other symbols. You can also use multiple symbols and separate them.
For example:
English and numbers plus the @ symbol plus some symbols: \ a-\ z \ A-\ Z0-9 \ u4E00-\ u9FA5 \@\.
If you want to right-click the menu in the text box and paste the information that cannot be copied, enter onKeyDown = "fncKeyStop (event) in <input>) "onpaste =" return false "oncontextmenu =" return false ;"