jQuery技术

Jquery.validate.js表单验证详解(4)

字号+ 作者:H5之家 来源:H5之家 2017-08-31 13:00 我要评论( )

Elements to ignore when validating, simply filtering them out. jQuerys not-method is used, therefore everything that is accepted by not() can be passed as this option. Inputs of type submit and reset

Elements to ignore when validating, simply filtering them out. jQuery's not-method is used, therefore everything that is accepted by not() can be passed as this option. Inputs of type submit and reset are always ignored, so are disabled elements.

Example: Ignores all elements with the class "ignore" when validating.

$("#myform").validate({ ignore: ".ignore" });

highlight (default:  Adds errorClass (see the option) to the element )

Type:  ()

How to highlight invalid fields. Override to decide which fields and how to highlight.

Example: Adds the error class to both the invalid element and its label

$("#myform").validate({ highlight: function(element, errorClass, validClass) { $(element).addClass(errorClass).removeClass(validClass); $(element.form).find("label[for=" + element.id + "]") .addClass(errorClass); }, unhighlight: function(element, errorClass, validClass) { $(element).removeClass(errorClass).addClass(validClass); $(element.form).find("label[for=" + element.id + "]") .removeClass(errorClass); } })

The callback gets passed three arguments:

  • element
  • Type: 

    The invalid DOM element, usually an  input .

  • errorClass
  • Type: 

    Current value of the  errorClass option.

  • validClass
  • Type: 

    Current value of the  validClass option.

    unhighlight (default:  Removes the errorClass )

    Type:  ()

    Called to revert changes made by option highlight, same arguments as highlight.


    分享给小伙伴们:

    本文标签: Jquery.valid,validate.js,validate,表单验证/">Jquery.valid,validate.js,validate,表单验证

    相关文章

  • 04.09
  • 07.25
  • 发表评论愿您的每句评论,都能给大家的生活添色彩,带来共鸣,带来思索,带来快乐。

  • 本类最热新闻

  •  

    1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

    相关文章
    • jquery.validate.js简介

      jquery.validate.js简介

      2017-02-25 13:04

    • JQuery表单验证插件jQuery.validate.js

      JQuery表单验证插件jQuery.validate.js

      2016-11-13 14:00

    • jQuery Validate.js参数以及使用教程

      jQuery Validate.js参数以及使用教程

      2015-09-23 15:15

    网友点评