1, cannot be empty
<input type="text" onblur="if((/^ +| +$/g,'')=='')alert('can't be empty!')">
2. Only enter English and numbers
<input onblur="if(/[^0-9a-zA-Z]/(value))alert('Wrong')">
<input onkeyup="value=(/[^0-9a-zA-Z]/g,'')"/>
<input type="text" onkeyup="value=(/[^\a-\z\A-\Z0-9]/g,'')">
3. Judgment: Characters are composed of letters and numbers, underscores, and dots. The only thing that starts is underscores and letters.
/^([a-zA-z_]{1})([\w]*)$/(str)
4. Only enter numbers
<input name="text" type="text" onKeyUp="value=(/\D/g,'')" onafterpaste="value=(/\D/g,'')" >
5. Only enter Chinese
<input type="text" onkeyup="value=(/[^\u4E00-\u9FA5]/g,'')">
6. Only enter English
<input type="text" onkeyup="value=(/[^\a-\z\A-\Z]/g,'')">
<input type="text" onkeyup="value=(/[^a-zA-Z]/g,'')">
7. Only enter Chinese, English, numbers, @ symbols and. symbols.
<input type="text" onkeyup="value=(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\@\.]/g,'')">
8. Only English is allowed, and the paste menu cannot be popped up.
<input type="text" onkeyup="value=(/[^\a-\z\A-\Z]/g,'')" onkeydown="fncKeyStop(event)" onpaste="return false" oncontextmenu = "return false"/>
Only numbers and dot numbers can be entered (Notice:D in [^\d\.] cannot be written in capital D, otherwise it will become all characters except numbers)
<input name="price" type="text" size="8" maxlength="8" onkeyup="value=(/[^\d\.]/g,'')" >
In short: first enter onkeyup="value=(/[^\X]/g,'')" in <input> and then replace the X in (/[\X]/g,'') with the code you want to enter.
Chinese:u4E00-u9FA5
number:d、0-9
English:a-z、A-Z
Other symbols @, dots or other symbols. You can also use multiple symbols, just separate them with \.
For example:
Chinese, English and numbers with @ symbols and dotted symbols: \a-\z\A-\Z0-9\u4E00-\u9FA5\@\.
If you want to not right-click the menu and cannot paste the copied information in the text box, you must enter onKeyDown="fncKeyStop(event)" onpaste="return false" oncontextmenu="return false;"