文档介绍:API
佚名(将pdf中内容整合到doc)
名称
返回类型
描述
validate(options)
返回:Validator
验证所选的FORM
valid()
返回:Boolean
检查是否验证通过
rules()
返回:Options
返回元素的验证规则
rules("add",rules)
返回:Options
增加验证规则
rules("remove",rules)
返回:Options
删除验证规则
removeAttrs(attributes)
返回:Options
删除特殊属性并且返回他们
Custom selectors
:blank
返回:Validator
没有值的筛选器
:filled
返回:Array <Element >
有值的筛选器
:unchecked
返回:Array <Element >
没选择的元素的筛选器
Utilities
(template,argument ,argumentN...)
返回:String
用参数代替模板中的{n}
 
 
Validator:
validate方法返回一个Validator对象,它有很多方法, 让你能使用引发校验程序或者改变form的内容. validator对象有很多方法,但下面只是列出常用的
form()
返回:Boolean
验证form返回成功还是失败
element(element)
返回:Boolean
验证单个元素是成功还是失败
resetForm()
返回:undefined
把前面验证的FORM恢复到验证前原来的状态
showErrors(errors)
返回:undefined
显示特定的错误信息
 
Validator functions:
setDefaults(defaults)
返回:undefined
改变默认的设置
addMethod(name,method,message)
返回:undefined
添加一个新的验证方法. 必须包括一个独一无二的名字,一个JAVASCRIPT的方法和一个默认的信息
addClassRules(name,rules)
返回:undefined
增加组合验证类型在一个类里面用多种验证方法里比较有用
addClassRules(rules)
返回:undefined
增加组合验证类型在一个类里面用多种验证方法里比较有用,这个是一下子加多个
 
 
内置验证方式:
required()
返回:Boolean
必填验证元素
required(dependency-expression)
返回:Boolean
必填元素依赖于表达式的结果
required(dependency-callback)
返回:Boolean
必填元素依赖于回调函数的结果
remote(url)
返回:Boolean
请求远程校验。url通常是一个远程调用方法
minlength(length)
返回:Boolean
设置最小长度
maxlength(length)
返回:Boolean
设置最大长度