1.表单选择器
:input
:text
:password
:radio
:checkbox
:submit
:image
:reset
:button
:file
:hidden
2.表单属性过滤器
:enabled
:disabled
:checked
:selected
3.表单验证常用事件
onblur事件,用blur()方法
onfocus事件,用focus()方法
select()方法选中文本
4.正则表达式(RegExp)
4.1.定义方式
普通方式:var expMobile = /^1\d{10}$/;
构造函数:var expPostCode = new RegExp("\d{6}","");
4.2.RegExp对象属性
g:全局匹配
i:忽略大小写
m:多行模式
4.3.常用符号
/../代表模式开始和结束(普通)
^ : 字符串开始
$ : 字符串结束
\s: 空白字符
\S: 非空白字符
\d: 数字
\D: 非数字字符
\w: 单字符(数字、字母、下划线)
\W: 非单字符
. : 任意字符
4.4.数量词
{n} n个
{n,} 至少n个
{n,m}n到m个
* 0到多个
+ 1到多个
? 0到1个
5.H5的表单验证
5.1.常用属性
placeholder
required
pattern
5.2.validity属性
valid: false//总属性,其它都为false这个才为true
badInput: true //浏览器无法完成类型转换,如number框输入abc
customError : true //存在自定义错误消息
patternMismatch:true //正则表达式验证失败
rangeOverflow: true //值超过max的限定
rangeUnderflow: true //值小于min的限定
tooLong : true //字符数超过maxlength
tooShort : true //字符数小于minlength
stepMismatch : true //数字不符合step限制(range等元素)
typeMismatch : true //值不符合email、url的验证
valueMissing : true //值为空,违反了required要求
5.3.验证消息提示
setCustomValidity("")
jQuery表单验证
最新推荐文章于 2022-11-22 10:34:00 发布