Quick Solution that JQuery. validate does not support in ie8, jquery. validateie8

Source: Internet
Author: User

Quick Solution that JQuery. validate does not support in ie8, jquery. validateie8

I. Back the problematic code in ie8

1. The JQuery. validate verification framework verifies whether the input in the <input/> label conforms to its own rules by submitting the form on the page.

<Form id = "cardTypeFrm"> <table width = "100%" cellspacing = "0" cellpadding = "0" class = "table_pzh"> <tbody> <tr> <th class = "f14 tr pc1"> User Name: </th> <td> <input type = "text" class = "pzh_input1" id = "userName" name = "userName"/> </td> </tr> <tr> <th class = "f14 tr pc1"> password: </th> <td> <input type = "text" class = "pzh_input1" id = "passWord" name = "passWord"/> </td> </tr> </tbody> </table> <p class = "pc2 undis pl50 error pa" style = "padding-left: 118px; margin-top:-10px; "id =" card_next_error "> error message </p> <div class =" m20 tc "> <input type =" submit "id =" submitCardNo "class =" define_button reservation_1" value = "login"/> <input type = "button" value = "cancel" class = "close_button closePzh ml10"/> </div> </form>

The name attribute is consistent with the attribute in the rules in the following js.

2. The code for binding the validate event in js is as follows:

$ (Function () {initCardTypeFrmValidate ()}) function initCardTypeFrmValidate () {$ ('# cardtypefrm '). validate ({onkeyup: false, onfocusout: false, rules: {userName: {required: true} passWord: {required: true }, messages: {userName: {required: 'Enter username'}, passWord: {required: 'enter password' }}, errorElement: "p "});}

Onkeyup: false, indicating that the keyboard input is not verified. The default value is true.
Onfocusout: false, indicating that the input box does not verify if the focus is lost. The default value is true.

2. The solution is to disable form submission on the page and bind a form submission form in js.

1. the html code remains unchanged.

<Form id = "cardTypeFrm"> <table width = "100%" cellspacing = "0" cellpadding = "0" class = "table_pzh"> <tbody> <tr> <th class = "f14 tr pc1"> User Name: </th> <td> <input type = "text" class = "pzh_input1" id = "userName" name = "userName"/> </td> </tr> <tr> <th class = "f14 tr pc1"> password: </th> <td> <input type = "text" class = "pzh_input1" id = "passWord" name = "passWord"/> </td> </tr> </tbody> </table> <p class = "pc2 undis pl50 error pa" style = "padding-left: 118px; margin-top:-10px; "id =" card_next_error "> error message </p> <div class =" m20 tc "> <input type =" submit "id =" submitCardNo "class =" define_button reservation_1" value = "login"/> <input type = "button" value = "cancel" class = "close_button closePzh ml10"/> </div> </form>

2. Bind and submit events in js Code

$ (Function () {initCardTypeFrmValidate () // optimization code $ ('# cardtypefrm '). submit (function () {if ($ ('# cardtypefrm '). valid () {// action executed} return false; // permanently prohibit page form submission}) function initCardTypeFrmValidate () {$ ('# cardtypefrm '). validate ({onkeyup: false, onfocusout: false, rules: {userName: {required: true} passWord: {required: true }, messages: {userName: {required: 'Enter username'}, passWord: {required: 'enter password' }}, errorElement: "p "});}

The quick solution that JQuery. validate does not support in ie8 is to share all the content with you. I hope to give you a reference and support for the customer's house.

Related Article

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.