1, cannot be empty
<input type= "text" onblur= "if (This.value.replace (/^ +|," ") = =") alert (' cannot be empty! ') " >
2, you can only input English and digital
<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 and numbers, underscores, and dots. And the beginning can only be underlined and letters.
/^ ([A-za-z_]{1}) ([\w]*) $/g.test (str)
4, you can only enter a number
<input name= "text" type= "text" id= "NewPage" onkeyup= "Value=value.replace" (/\d/g, "" onafterpaste= "value=") Value.replace (/\d/g, ")" >
5, you can only enter Chinese
<input type= "text" onkeyup= "Value=value.replace (/[^\u4e00-\u9fa5]/g, ')" >
6, you can only enter English
<input type= "text" onkeyup= "Value=value.replace (/[^\a-\z\a-\z]/g, ')" >
<input type= "text" onkeyup= "Value=value.replace (/[^a-za-z]/g, ')" >
7, you can only enter Chinese, English, numerals, @ symbols and. Symbols
<input type= "text" onkeyup= "Value=value.replace (/[^\a-\z\a-\z0-9\u4e00-\u9fa5\@\.] /g, ') ' >
8, only allowed to enter English, and can not paste or pop-up paste menu
<input type= "text" onkeyup= "Value=value.replace (/[^\a-\z\a-\z]/g, '") "onkeydown=" Fnckeystop (event) "Onpaste=" return false ' OnContextMenu = ' return false '/>
You can only enter numbers and dots ( Note: in [^\d\.] D can not be written in uppercase D, otherwise it will become all except the number of characters)
<input name= "Price" type= "text" size= "8" maxlength= "8" onkeyup= "Value=value.replace" (/[^\d\.] /g, ') ' >
All in all: First enter onkeyup= in <input> "Value=value.replace (/[^\x]/g,") and then in (/[\x]/g, "") Replace the X you want to enter the code you can
Chinese : u4e00-u9fa5
number : D, 0-9
English : A-Z, A-Z
Other symbols @, dots, or other symbols. Can also be multiple, separated on the line.
For example:
Chinese, English and digit @ sign with dot symbol: \a-\z\a-\z0-9\u4e00-\u9fa5\@\.
If you want to be in the text box can not right-click pop-up menu and can not paste into the copy of the information in the <input> input onkeydown= "Fnckeystop (event)" onpaste= "return false" OnContextMenu = "return false;"