Jquery.validate Manual (3)

Source: Internet
Author: User

1: Custom form submission

Set Submithandler to customize form submission actions

$ (". Selector"). Validate ({
Submithandler:function (form) {alert ("Validate Pass");}
});

If you need to submit a form, you can call
Form.submit (); or $ (form). Ajaxsubmit ();

2: Debug mode

Set Debug to True, the form will not be submitted, only checked, easy to debug

$ (". Selector"). Validate ({
Debug:true
})

3: Set default value for Validate

Use SetDefaults to set default values for validate, such as all form validation by default in debug mode

$.validator.setdefaults ({
Debug:true
})

4: Some elements do not validate

Setting the Ignore property can omit certain elements from being validated

$ (". Selector"). Validate ({
Ignore: "Ignore"
})

5: Time to verify

Jquery.validate can be conveniently set when the verification action is triggered

OnSubmit: Whether to validate at commit

$ (". Selector"). Validate ({
Onsubmit:false
})

Onfocusout: Validation when losing focus (except Checkboxes/radio)

$ (". Selector"). Validate ({
Onfocusout:false
})

OnKeyUp: Validating at KeyUp

$ (". Selector"). Validate ({
Onkeyup:false
})

OnClick: Verified when checkboxes, radio clicked.

$ (". Selector"). Validate ({
Onclick:false
})

6: Overriding validation rules and validation tips

Overriding the validation hints for max
$.validator.messages.max = Jquery.format ("Your totals Musn ' t exceed {0}!");

Overriding the Equal method
$.validator.methods.equal = function (value, element, param) {
return value = = param;
};

7:focusinvalid whether to focus on the last action or the most recent error

$ (". Selector"). Validate ({
Focusinvalid:false
})

8:focuscleanup

If the property is set to true, the control obtains the focus, removing the wrong class definition, hiding the error message, and avoiding focusinvalid.

$ (". Selector"). Validate ({
Focuscleanup:true
})

9:meta

Set meta to encapsulate validation rules

$ (". Selector"). Validate ({
Meta: "Validate",
})

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.