<input type=‘text’ id=‘SYS_PAGE_JumpPage’ name=‘SYS_PAGE_JumpPage’ size=‘3’ maxlength=‘5’ οnkeyup=‘this.value=this.value.replace(/[^1-9]\D*$/,"")’ οndragenter=“return false” οnpaste=“return !clipboardData.getData(‘text’).match(/\D/)”" style=“ime-mode:disabled;”>
1.只能输入数字和英文的:
2.只能输入数字的:
3.只能输入全角的:
4.只能输入汉字的:
5.邮件地址验证:
var regu = “^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$”
var re = new RegExp(regu);
if (s.search(re) != -1) {
return true;
} else {
window.alert (“请输入有效合法的E-mail地址 !”)
return false;
}
6.身份证:
“^\d{17}(\d|x)$”
7.17种正则表达式
“^\d+
"
/
/
非
负
整
数
(
正
整
数
+
0
)
"
[
0
−
9
]
∗
[
1
−
9
]
[
0
−
9
]
∗
" //非负整数(正整数 + 0) "^[0-9]*[1-9][0-9]*
" //非负整数(正整数+0)"[0−9]∗[1−9][0−9]∗” //正整数
“^((-\d+)|(0+))
"
/
/
非
正
整
数
(
负
整
数
+
0
)
"
−
[
0
−
9
]
∗
[
1
−
9
]
[
0
−
9
]
∗
" //非正整数(负整数 + 0) "^-[0-9]*[1-9][0-9]*
" //非正整数(负整数+0)"−[0−9]∗[1−9][0−9]∗” //负整数
“^-?\d+KaTeX parse error: Got function '\newline' with no arguments as superscript at position 12: " //整数 "^̲\\d+(\\.\\d+)?” //非负浮点数(正浮点数 + 0)
“^(([0-9]+\.[0-9][1-9][0-9])|([0-9][1-9][0-9]\.[0-9]+)|([0-9][1-9][0-9]))
"
/
/
正
浮
点
数
"
(
(
−
d
+
(
.
d
+
)
?
)
∣
(
0
+
(
.
0
+
)
?
)
)
" //正浮点数 "^((-\\d+(\\.\\d+)?)|(0+(\\.0+)?))
" //正浮点数"((−d+(.d+)?)∣(0+(.0+)?))” //非正浮点数(负浮点数 + 0)
“^(-(([0-9]+\.[0-9][1-9][0-9])|([0-9][1-9][0-9]\.[0-9]+)|([0-9][1-9][0-9])))
"
/
/
负
浮
点
数
"
(
−
?
d
+
)
(
.
d
+
)
?
" //负浮点数 "^(-?\\d+)(\\.\\d+)?
" //负浮点数"(−?d+)(.d+)?” //浮点数
“1+
"
/
/
由
26
个
英
文
字
母
组
成
的
字
符
串
"
[
A
−
Z
]
+
" //由26个英文字母组成的字符串 "^[A-Z]+
" //由26个英文字母组成的字符串"[A−Z]+” //由26个英文字母的大写组成的字符串
“2+
"
/
/
由
26
个
英
文
字
母
的
小
写
组
成
的
字
符
串
"
[
A
−
Z
a
−
z
0
−
9
]
+
" //由26个英文字母的小写组成的字符串 "^[A-Za-z0-9]+
" //由26个英文字母的小写组成的字符串"[A−Za−z0−9]+” //由数字和26个英文字母组成的字符串
“^\w+
"
/
/
由
数
字
、
26
个
英
文
字
母
或
者
下
划
线
组
成
的
字
符
串
"
[
w
−
]
+
(
.
[
w
−
]
+
)
∗
@
[
w
−
]
+
(
.
[
w
−
]
+
)
+
" //由数字、26个英文字母或者下划线组成的字符串 "^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+
" //由数字、26个英文字母或者下划线组成的字符串"[w−]+(.[w−]+)∗@[w−]+(.[w−]+)+” //email地址
“3+://(\w+(-\w+))(\.(\w+(-\w+)))(\?\S)?$” //url
=============================================
1.取消按钮按下时的虚线框
在input里添加属性值 hideFocus 或者 HideFocus=true
2.只读文本框内容
在input里添加属性值 readonly
3.防止退后清空的TEXT文档(可把style内容做做为类引用)
4.ENTER键可以让光标移到下一个输入框
5.只能为中文(有闪动)
<input οnkeyup=“value=”/value.replace(/[" -~]/g,’’)" οnkeydοwn=“if(event.keyCode==13)event.keyCode=9”>
6.只能为数字(有闪动)
<input οnkeyup=“value=”/value.replace(/["^\d]/g,’’) "onbeforepaste=“clipboardData.setData(’text’,clipboardData.getData(’text’).replace(/[^\d]/g,’’))”>
7.只能为数字(无闪动)
<input ime-mode:disabled" οnkeydοwn=“if(event.keyCode==13)event.keyCode=9” onKeyPress=“if ((event.keyCode<48 || event.keyCode>57)) event.returnValue=false”>
8.只能输入英文和数字(有闪动)
<input οnkeyup=“value=”/value.replace(/[\W]/g,"’’)" onbeforepaste=“clipboardData.setData(’text’,clipboardData.getData(’text’).replace(/[^\d]/g,’’))”>
9.屏蔽输入法
<input type=“text” name=“url” ime-mode:disabled" οnkeydοwn=“if(event.keyCode==13)event.keyCode=9”>
-
只能输入 数字,小数点,减号(-) 字符(无闪动)
-
只能输入两位小数,三位小数(有闪动)
<input maxlength=9 οnkeyup=“if(value.match(/^\d{3}KaTeX parse error: Can't use function '\.' in math mode at position 77: …value.replace(/\̲.̲\d*\./g,’."’)" …/) || /.\d{3}$/.test(value)) {event.returnValue=false}” id=text_kfxe name=text_kfxe>
原文
https://www.cnblogs.com/xingluzhe/p/4800085.html