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.