the input box cannot be empty
<input onblur= "if (This.value.replace (/^ +| +$/g, ') = =") alert (' cannot be empty! ') " >
Only English and numbers can be entered
<input onblur= "if (/[^0-9a-za-z]/g.test (value)) alert (' wrong ') ' >
<input onkeyup= "Value=value.replace (/[^0-9a-za-z]/g, ')"/>
<input type= "text" onkeyup= "Value=value.replace (/[^\a-\z\a-\z0-9]/g, ')" >
The judging character consists of a letter and a number, an underscore, and a dot. And only the underscore and the letter can begin
/^ ([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, ') ">
You can only enter Chinese
<input type= "text" onkeyup= "Value=value.replace (/[^\u4e00-\u9fa5]/g, ')" >
Can only be entered in English
<input type= "text" onkeyup= "Value=value.replace (/[^\a-\z\a-\z]/g, ')" >
<input type= "text" onkeyup= "Value=value.replace (/[^a-za-z]/g, ')" >
You can only enter Chinese, English, numbers, @ symbols, and. Symbols
<input type= "text" onkeyup= "Value=value.replace (/[^\a-\z\a-\z0-9\u4e00-\u9fa5\@\.] /g, ') ' >
Only English is allowed and cannot be pasted or pop-up menu
<input type= "text" onkeyup= "Value=value.replace (/[^\a-\z\a-\z]/g, ')" onkeydown= "Fnckeystop (event)" Onpaste= " return false "OnContextMenu =" return false "/>
Only numbers and dot numbers can be entered (note: in [^\d\.] D cannot be written in uppercase D, otherwise it becomes all characters except the number.
<input name= "Price" type= "text" size= "8" maxlength= "8" onkeyup= "Value=value.replace (/[^\d\.] /g, ') ' >
All in all: First enter onkeyup= "Value=value.replace (/[^\x]/g,") in <input> and then X in (/[\x]/g, ") to the code you want to enter.
English : u4e00-u9fa5
numbers : D, 0-9
English : A-Z, A-Z
Other symbols @, dots, or other symbols. Can also be multiple, with \ Separated on the line.
For example:
Add symbols in Chinese, English, and digital plus @ symbols: \a-\z\a-\z0-9\u4e00-\u9fa5\@\.
If you want to not right-click in the text box pop-up menu and can not paste into the copied information, you will enter the <input> onkeydown= "Fnckeystop (event)" onpaste= "return false" OnContextMenu = "return false;"
JS Various validation text box input content format