jQuery validator plugin之Validator
Validator.destroy()
Destroys this instance of validator freeing up resources and unregistering events.
jQuery.validator.methods
Object holding all validation methods known to the validator. This can be accessed to override individual methods, while keeping the default messages.
jQuery.validator.addClassRules()
-
jQuery.validator.addClassRules( name, rules )
-
jQuery.validator.addClassRules( rules )
-
rulesType: ObjectA map of className-rules pairs (see example).
-
jQuery.validator.setDefaults()
-
jQuery.validator.setDefaults( options )
-
optionsType: ObjectOptions to set as default.
-
Accepts everything that validate() accepts.
jQuery.validator.format()
One or more arguments can be passed, in addition to the string template itself, to insert into the string.
If you're familiar with the term, this makes this function support currying. If you don't care about that, just use the first argument.
jQuery.validator.addMethod()
Add a custom validation method. It must consist of a name (must be a legal javascript identifier), a javascript based function and a default string message.
-
jQuery.validator.addMethod( name, method [, message ] )
-
nameType: StringThe name of the method used to identify it and referencing it; this must be a valid JavaScript identifier
-
methodType: Function()The actual method implementation, returning true if an element is valid. First argument: Current value. Second argument: Validated element. Third argument: Parameters.
-
valueType: Stringthe current value of the validated element
-
elementType: Elementthe element to be validated
-
paramsType: Objectparameters specified for the method, e.g. for min: 5, the parameter is 5, for range: [1, 5] it's [1, 5]
-
messageType: StringThe default message to display for this method. Can be a function created by ''jQuery.validator.format(value)''. When undefined, an existing message is used (handy for localization), otherwise the field-specific messages have to be defined.
-
-
For simple one-off validation, you can use the bundled pattern
method (in additional methods, source in src/additional/pattern.js
) to validate a field against a regular expression.
In general, it is a good idea to encapsulate those regular expressions inside their own method.
If you need lots of slightly different expressions, try to extract a common parameter.
See also a library of regular expressions.
Validator.showErrors()
Show the specified messages.
-
Validator.showErrors( errors )
-
errorsType: ObjectOne or more key/value pairs of input names and messages.
-
Validator.resetForm()
Resets the controlled form.
Validator.numberOfInvalids()
-
Validator.numberOfInvalids( errors )
-
errorsType: ObjectOne or more key/value pairs of input names and messages.
-
Returns the number of invalid fields.
Validator.form()
Validates the form, returns true if it is valid, false otherwise.
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· 没有源码,如何修改代码逻辑?
· NetPad:一个.NET开源、跨平台的C#编辑器
· 面试官:你是如何进行SQL调优的?
2017-12-27 facebook ads api
2017-12-27 Kubernetes命令
2017-12-27 Docker 命令