|
1 |
| -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
2 |
| -<htmlxmlns="http://www.w3.org/1999/xhtml"xml:lang="en"lang="en"> |
| 1 | +<!DOCTYPE html> |
| 2 | +<htmllang="en"> |
3 | 3 | <head>
|
4 |
| - |
| 4 | +<metacharset="utf-8"> |
5 | 5 | <title>jQuery accordion form with validation</title>
|
6 | 6 |
|
7 |
| -<linkrel="stylesheet"href="../assets/demo_blue.css"type="text/css"/> |
| 7 | +<scriptsrc="../../lib/jquery.js"></script> |
| 8 | +<scriptsrc="../../jquery.validate.js"></script> |
8 | 9 |
|
9 |
| -<scripttype="text/javascript"src="../../lib/jquery.js"></script> |
10 |
| -<scripttype="text/javascript"src="../../jquery.validate.js"></script> |
11 |
| -<scripttype="text/javascript"src="js/jquery.maskedinput-1.0.js"></script> |
12 |
| -<scripttype="text/javascript"src="js/ui.core.js"></script> |
13 |
| -<scripttype="text/javascript"src="js/ui.accordion.js"></script> |
| 10 | +<scriptsrc="../marketo/jquery.maskedinput.js"></script> |
| 11 | +<scriptsrc="http://code.jquery.com/ui/1.10.2/jquery-ui.min.js"></script> |
14 | 12 |
|
15 | 13 | <scripttype="text/javascript">
|
16 | 14 | $(document).ready(function(){
|
17 | 15 |
|
18 | 16 | $("#recordClientPhone").mask("(999) 999-9999");
|
19 | 17 | $("#recordClientPhoneAlt").mask("(999) 999-9999");
|
20 | 18 | $("#recordClientZip").mask("99999");
|
21 |
| -$("#recordPropertyZip").mask("99999"); |
22 |
| -$("#recordPurchaseZip").mask("99999"); |
| 19 | +$("#recordPropertyZip").mask("99999"); |
| 20 | +$("#recordPurchaseZip").mask("99999"); |
23 | 21 |
|
24 | 22 | // add * to required field labels
|
25 | 23 | $('label.required').append(' <strong>*</strong> ');
|
26 | 24 |
|
27 | 25 | // accordion functions
|
28 |
| -varaccordion=$("#stepForm").accordion(); |
| 26 | +varaccordion=$("#stepForm").accordion(); |
29 | 27 | varcurrent=0;
|
30 |
| -
|
| 28 | + |
31 | 29 | $.validator.addMethod("pageRequired",function(value,element){
|
32 | 30 | var$element=$(element)
|
33 | 31 | functionmatch(index){
|
|
38 | 36 | }
|
39 | 37 | return"dependency-mismatch";
|
40 | 38 | },$.validator.messages.required)
|
41 |
| -
|
| 39 | + |
42 | 40 | varv=$("#cmaForm").validate({
|
43 | 41 | errorClass:"warning",
|
44 | 42 | onkeyup:false,
|
|
47 | 45 | alert("Submitted, thanks!");
|
48 | 46 | }
|
49 | 47 | });
|
50 |
| -
|
| 48 | + |
51 | 49 | // back buttons do not need to run validation
|
52 | 50 | $("#sf2 .prevbutton").click(function(){
|
53 |
| -accordion.accordion("activate",0); |
| 51 | +accordion.accordion("option","active",0); |
54 | 52 | current=0;
|
55 |
| -}); |
| 53 | +}); |
56 | 54 | $("#sf3 .prevbutton").click(function(){
|
57 |
| -accordion.accordion("activate",1); |
| 55 | +accordion.accordion("option","active",1); |
58 | 56 | current=1;
|
59 |
| -}); |
| 57 | +}); |
60 | 58 | // these buttons all run the validation, overridden by specific targets above
|
61 | 59 | $(".open2").click(function(){
|
62 | 60 | if(v.form()){
|
63 |
| -accordion.accordion("activate",2); |
| 61 | +accordion.accordion("option","active",2); |
64 | 62 | current=2;
|
65 | 63 | }
|
66 | 64 | });
|
67 | 65 | $(".open1").click(function(){
|
68 | 66 | if(v.form()){
|
69 |
| -accordion.accordion("activate",1); |
| 67 | +accordion.accordion("option","active",1); |
70 | 68 | current=1;
|
71 | 69 | }
|
72 | 70 | });
|
73 | 71 | $(".open0").click(function(){
|
74 | 72 | if(v.form()){
|
75 |
| -accordion.accordion("activate",0); |
| 73 | +accordion.accordion("option","active",0); |
76 | 74 | current=0;
|
77 | 75 | }
|
78 | 76 | });
|
79 |
| -
|
| 77 | + |
80 | 78 | });
|
81 | 79 | </script>
|
82 | 80 |
|
|