-
-
用正则表达式控制输入格式
-
-
-
"1"> -
-
|
只能输入中文: | -
- "text" name="mark" onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))" />
-
| -
-
-
|
只能输入数字: | -
- "text" name="number" onkeyup="value=value.replace(/[^\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />
-
| -
-
-
|
只能输入数字和英文: | -
- "text" name="alpha" onkeyup="value=value.replace(/[\W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />
-
| -
-
-
|
只能输入数字和英文还有中文: | -
- "text" name="chinese" onkeyup="value=value.replace(/[^\u4E00-\u9FA5^a-z^A-Z^0-9]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5^a-z^A-Z^0-9]/g,''))" />
-
| -
-
| "2">"submit"/> |
-
-
-
-
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/11134734/viewspace-659502/
,如需转载,请注明出处,否则将追究法律责任。