Makes the element require a given step.

 

normalizer

Prepares/transforms the elements value for validation.

Transform the value of an element and the result for validation instead of the initial value.

The normalizer can be defined global to all elements or local to only one element.

  • With that said, the local normalizer will only run for the element for which it was defined.
  • The global normalizer will run for all validated elements.

This normalizer can be then overrided for each element, as needed, by attaching one to it.

This way only the local one will run for that element, and the global one will run for others.

Note that this method:

  • Doesn't change the elements' value, it only changes the value used for validation.
  • Gets the value passed as argument, and "this" within it references the corresponding DOMElement.
  • Needs to return a String value, otherwise it will throw a TypeError exception.

require_from_group method

Ensures a given number of fields in a group are complete.

In the options passed to the rule, supply the minimum number of fields
within the group that must be complete and a selector to define the
group.

Then apply this rule to all the fields within the group.
The form then cannot be submitted until at least the minimum number have
been completed.

Part of the additional-methods.js file

url method

Makes the element require a valid url

Return true, if the value is a valid url.

Works with text inputs.

required method

Makes the element required.

  • required()

  • required( dependency-expression )

    • dependency-expression
      Type: String
      An expression (String) that is evaluated in the context of the element's
      form, making the field required only if the expression returns more
      than one element.
  • required( dependency-callback )

    • dependency-callback
      Type: Function()
      The function is executed with the element as it's only argument: If it returns true, the element is required. 
      • Return false, if the element is empty (text input) or unchecked (radio/checkbox) or if nothing is selected (select).
      • Works with text inputs, selects, checkboxes and radio buttons.
      • To force a user to select an option from a select box, provide an empty
        option element like <option value="">Choose…</option>
      • Note that white spaces are considered valid.

remote method

  • remote( options )

    • Requests a resource to check the element for validity.
    • options
      Type: Object
      For the URL of the resource to request for serverside validation (String) or options to fully customize the request, see jQuery.ajax for details.
      • These options deep-extend the defaults (dataType:"json", data:{nameOfTheElement:valueOfTheElement}). Any options you provide will override the defaults.
    • The serverside resource is called via jQuery.ajax (XMLHttpRequest) and
      gets a key/value pair corresponding to the name of the validated element
      and its value as a GET parameter.

      • The serverside response must be a
        JSON string that must be "true" for valid elements, and can be "false", undefined, or null for invalid elements, using the default error message.
      • If the serverside response is a string, eg. "That name is already taken, try peter123 instead", this string will be displayed as a custom error message in place of the default.
      • For more examples, take a look the marketo demo and the milk demo.

rangelength method

Return false if the element is:

  • some kind of text input and its length is too short or too long
  • a set of checkboxes that doesn't have enough, or has too many boxes checked
  • a select that doesn't have enough, or has too many options selected

Works with text inputs, selects and checkboxes.

range method

phoneUS method

Validate for valid US phone number.

Works with text inputs.

Part of the additional-methods.js file

number method

Makes the element require a decimal number.

Returns true if the value contains a valid decimal number.

Works with text inputs.

  • value
    Type: Number
    Step value required 

jQuery validator plugin之Methods的更多相关文章

  1. jQuery validator plugin 之 custom methods 案例1:multi email

    1.add method jQuery.validator.addMethod( "multiemail", function (value, element) { var ema ...

  2. jQuery validator plugin之概要

    jQuery validator 主页 github地址 demo学习 效果: Validate forms like you've never validated before! 自定义Valida ...

  3. jQuery validator plugin之Validator

    Validator.destroy() Destroys this instance of validator freeing up resources and unregistering event ...

  4. jQuery validator plugin之Plugin Method

    原文 .validate() validate( [options ] ) options Type: Object debug (default: false) Type: Boolean Enab ...

  5. jQuery validator plugin之Selector

    原文 :unchecked Selector Selects all elements that are unchecked. jQuery( ":unchecked" ) Inv ...

  6. jQuery.validator 详解二

    前言:上一篇详细的介绍了jQuery.validator( 版本v1.13.0 )的验证规则,这一篇重点讲述它的源码结构,及如何来对元素进行验证,错误消息提示的内部实现 一.插件结构(组织方式) 在讲 ...

  7. jQuery.validator 详解

    jQuery.validator 详解二 前言:上一篇详细的介绍了jQuery.validator( 版本v1.13.0 )的验证规则,这一篇重点讲述它的源码结构,及如何来对元素进行验证,错误消息提示 ...

  8. jQuery Validation Plugin学习

    http://blog.csdn.net/violet_day/article/details/14109261 jQuery Validation Plugin Demo 一.默认校验规则 (1)r ...

  9. (转)jquery.validator规则

      登录|注册     收藏成功 确定 收藏失败,请重新收藏 确定 标题 标题不能为空 网址 标签 摘要   公开 取消收藏             分享资讯 传PPT/文档 提问题 写博客 传资源 ...

随机推荐

  1. hibernate06--参数的绑定

    创建Dept实体类 以及 对应的 Dept.hbm.xml文件 /** * @author 小豆腐 * *部门的实体类 */ public class Dept { private Integer d ...

  2. 目前常用的加密算法有DES(Data Encryption Standard)和IDEA(International Data Encryption Algorithm)国际数据加密算法等,请用工厂方法实现加密算法系统。提交该系统的代码,该系统务必是一个可以能够直接使用的系统,查阅资料完成相应加密算法的实现;

    1.加密算法的类图结构 2.源代码 2.1代码运行截图 2.2代码的目录结构 2.3具体代码 MethodFactory.java package jiami; public interface Me ...

  3. MySQL数据查询

    数据查询语言DQL select [all | distinct] 字段或表达式列表 [from子句] [where子句] [group by子句] [having子句] [order by子句] [ ...

  4. 个人小爱好:Operating System:three easy pieces---第6章第4节_担心并发问题?

    担心并发问题? 微妙,上下文切换大约6微妙.而,现在的系统有着级数级别的提升,在2-3GHz的处理起中消耗只有亚微妙级. 但应该注意到,不是所有的系统性能都跟着CPU性能的提升而提升,根据Ouster ...

  5. css学习_div+css布局

    1.布局(盒子布局.盒子模型.标准流.脱离文档流) 标准文档流:块级独占一行  ,行内块和行内元素都是和其他共占一行,在盒子中的元素遵循标准流从左到右从上到下排列,超过父元素时会溢出. 一行行看 浮动 ...

  6. 算法基础_递归_给定m个A,n个B,一共有多少种排列

    问题描述: 给定m个A,n个B,一共有多少种排列 解题源代码: /** * 给定m个A,n个B,问一共有多少种排列 * @author Administrator * */ public class ...

  7. Luogu 1023 - 税收与补贴问题 - [数学题]

    题目链接:https://www.luogu.org/problemnew/show/P1023 题目背景每样商品的价格越低,其销量就会相应增大.现已知某种商品的成本及其在若干价位上的销量(产品不会低 ...

  8. torch.nn.Embedding

    自然语言中的常用的构建词向量方法,将id化后的语料库,映射到低维稠密的向量空间中,pytorch 中的使用如下: import torch import torch.utils.data as Dat ...

  9. Spring Boot核心注解@SpringBootApplication

    一.作用   @SpringBootApplication是一个组合注解,用于快捷配置启动类. 二.用法   可配置多个启动类,但启动时需选择以哪个类作为启动类来启动项目. 三.拆解 1.拆解     ...

  10. 16.4-uC/OS-III同步 (任务信号量)

    信号量和消息队列均是单独的内核对象,是独立于任务存在的. 任务信号量 仅发布给一个特定任务 .任务消息队列 可以发布给多个任务. 任务信号量伴随任务存在,只要创建了任务,其任务信号量就是该任务的一个数 ...