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. OOD之问题空间到解空间—附FP的建模

    通常会被问到,什么事OOD,然后大部分人期待的答案比较死板,继承.封装.多态!懂这个的人多的去了,有什么好问?回答出来的人是否拿着Java又去做一些面向过程的勾当? 计算机革命起源于机器,因此编程语言 ...

  2. 网站美化:CSS3自定义修改浏览器滚动条

    滚动条组件 ::-webkit-scrollbar //滚动条整体部分 ::-webkit-scrollbar-thumb //滚动条里面的小方块,能向上向下移动(或往左往右移动,取决于是垂直滚动条还 ...

  3. Gitlab之版本回滚

    gitlab提交错误需要回滚版本 首先查看log找到需要回滚的head git log 回滚 git reset --hard 297ff2dcf20605297684f296a4b4ccaa1cf4 ...

  4. Linux命令 printf

    定长: $ printf '%s\t%s\t%s\t%s\t%s\t\n' $(cat printf.txt) # %s 表示一个不固定长度的字符串:printf不是管道命令,因此需要通过类似cat的 ...

  5. 图->连通性->关节点和重连通分量

    文字描述 相关定义:假若在删去顶点v以及和v相关联的各边之后,将图的一个连通分量分割成两个或两个以上的连通分量,则称顶点v为该图的一个关节点.一个没有关节点的连通图称为重连通图. 在重连通图上,任意一 ...

  6. 上传js,js修改html

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. 洛谷P3178 树上操作 [HAOI2015] 树链剖分

    正解:树链剖分+线段树 解题报告: 传送门! 树链剖分+线段树算是基操了趴,,, 就无脑码码码,没有任何含金量,不需要动脑子,然后码量其实也不大,就很爽 比树剖的板子还要板子一些hhhhh 放下代码就 ...

  8. ffmpeg的编译和安装

    1. 先到ffmpeg官网上下载ffmpeg源码,然后配置.编译 http://ffmpeg.org/download.html 可以如下进行配置: ./configure --prefix=/usr ...

  9. SparkML之推荐引擎(一)---电影推荐

    本文将使用 SparkML 来构建推荐引擎. 推荐引擎算法大致分为 基于内容的过滤.协同过滤.矩阵分解,本文将使用基于属于矩阵分解的 最小二乘法 算法来构建推荐引擎. 对于推荐引擎模块这里将分为两篇文 ...

  10. Python返回多个值

    def get_abc(): a = 1 b = 2 c = 3 return a,b,c temp = get_abc() #temp = (1,2,3) a,b,c = get_abc() #a ...