JQuery. validate does not support solutions in ie8-float leaf 1 and problematic code in ie8
1. The JQuery. validate verification framework is submitted and verified through the form on the page.Whether the tag matches your own rules
1
2
3
4
5
User name: | 6
78 | 9
10
11
Password: | 12
1314 | 15
16
17
18
Error Message
19
202122
23
Html code
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:
1 $ (function () {2 initCardTypeFrmValidate () 3}) 4 5 function initCardTypeFrmValidate () {6 7 $ ('# cardtypefrm '). validate ({8 onkeyup: false, 9 onfocusout: false, 10 rules: {11 userName: {required: true} 12 passWord: {required: true} 13}, 14 15 messages: {16 userName: {required: 'Enter the userName '}, 17 passWord: {required: 'Enter the password'} 18}, 19 errorElement: "p" 20 }); 21}
Js Code
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.
1
2
3
4
5
User name: | 6
78 | 9
10
11
Password: | 12
1314 | 15
16
17
18
Error Message
19
202122
23
2. Bind and submit events in js Code
1 $ (function () {2 initCardTypeFrmValidate () 3 // optimization code 4 $ ('# cardtypefrm '). submit (function () {5 6 if ($ ('# cardtypefrm '). valid () {7 // action executed 8} 9 return false; // permanently prohibit page form submission 10}) 11}) 12 13 function initCardTypeFrmValidate () {14 15 $ ('# cardtypefrm '). validate ({16 onkeyup: false, 17 onfocusout: false, 18 rules: {19 userName: {required: true} 20 passWord: {required: true} 21}, 22 23 messages: {24 userName: {required: 'Enter the userName '}, 25 passWord: {required: 'Enter the password'} 26}, 27 errorElement: "p" 28 }); 29}