1, cannot be blank
<Input type = "text" onblur = "If (this. value. replace (/^ + | + $/g, '') ='') Alert ('cannot be blank! ') ">
2. 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,'') ">
3. The 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)
4. Only numbers can be entered.
<Input name = "text" type = "text" id = "Newpage" onkeyup = "value = value. replace (/\ D/g, '')" onafterpaste = "value = value. replace (/\ D/g, '')">
5. Only Chinese characters can be entered.
<Input type = "text" onkeyup = "value = value. Replace (/[^ \ u4e00-\ u9fa5]/g,'') ">
6. Only English letters can be entered.
<Input type = "text" onkeyup = "value = value. Replace (/[^ \ A-\ Z]/g,'') ">
<Input type = "text" onkeyup = "value = value. Replace (/[^ A-Za-Z]/g,'') ">
7. 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, '')">
8. You can enter only English letters, and the paste menu cannot be displayed.
<Input type = "text" onkeyup = "value = value. replace (/[^ \ 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 replace X in (/[\ x]/g, '') withCodeYou can.
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 ;"