hjg
2024-07-09 30304784e82d4bba24121328da8eb8490aec4f4f
提交 | 用户 | 时间
58d006 1 <!DOCTYPE html>
A 2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
5 <title>Test for jQuery validate() plugin</title>
6
7 <link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />
8
9 <script src="../lib/jquery.js" type="text/javascript"></script>
10 <script src="../lib/jquery.metadata.js" type="text/javascript"></script>
11 <script src="../jquery.validate.js" type="text/javascript"></script>
12
13 <script type="text/javascript">
14 // only for demo purposes
15 $.validator.setDefaults({
16     submitHandler: function() {
17         alert("submitted!");
18     }
19 });
20     
21 $.metadata.setType("attr", "validate");
22
23 $(document).ready(function() {
24     $("#form1").validate();
25     $("#selecttest").validate();
26 });
27 </script>
28
29 <style type="text/css">
30 .block { display: block; }
31 form.cmxform label.error { display: none; }    
32 </style>
33
34 </head>
35 <body>
36
37 <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">jQuery Validation Plugin</a> Demo</h1>
38 <div id="main">
39
40 <form class="cmxform" id="form1" method="get" action="">
41     <fieldset>
42         <legend>Validating a form with a radio and checkbox buttons</legend>
43         <fieldset>
44             <legend>Gender</legend>
45             <label for="gender_male">
46                 <input  type="radio" id="gender_male" value="m" name="gender" validate="required:true" />
47                 Male
48             </label>
49             <label for="gender_female">
50                 <input  type="radio" id="gender_female" value="f" name="gender"/>
51                 Female
52             </label>
53             <label for="gender" class="error">Please select your gender</label>
54         </fieldset>
55         <fieldset>
56             <legend>Family</legend>
57             <label for="family_single">
58                 <input  type="radio" id="family_single" value="s" name="family" validate="required:true" />
59                 Single
60             </label>
61             <label for="family_married">
62                 <input  type="radio" id="family_married" value="m" name="family" />
63                 Married
64             </label>
65             <label for="family_other">
66                 <input  type="radio" id="family_other" value="o" name="family" />
67                 Other
68             </label>
69             <label for="family" class="error">Please select your family status.</label>
70         </fieldset>
71         <p>
72             <label for="agree">Please agree to our policy</label>
73             <input type="checkbox" class="checkbox" id="agree" name="agree" validate="required:true" />
74             <br/>
75             <label for="agree" class="error block">Please agree to our policy!</label>
76         </p>
77         <fieldset>
78             <legend>Spam</legend>
79             <label for="spam_email">
80                 <input type="checkbox" class="checkbox" id="spam_email" value="email" name="spam[]" validate="required:true, minlength:2" />
81                 Spam via E-Mail
82             </label>
83             <label for="spam_phone">
84                 <input type="checkbox" class="checkbox" id="spam_phone" value="phone" name="spam[]" />
85                 Spam via Phone
86             </label>
87             <label for="spam_mail">
88                 <input type="checkbox" class="checkbox" id="spam_mail" value="mail" name="spam[]" />
89                 Spam via Mail
90             </label>
91             <label for="spam[]" class="error">Please select at least two types of spam.</label>
92         </fieldset>
93         <p>
94             <input class="submit" type="submit" value="Submit"/>
95         </p>
96     </fieldset>
97 </form>
98
99 <form id="selecttest">
100     <h2>Some tests with selects</h2>
101     <p>
102         <label for="jungle">Please select a jungle noun</label><br/>
103         <select id="jungle" name="jungle" title="Please select something!" validate="required:true">
104             <option value=""></option>
105             <option value="1">Buga</option>
106             <option value="2">Baga</option>
107             <option value="3">Oi</option>
108         </select>
109     </p>
110     
111     <p>
112         <label for="fruit">Please select at least two fruits</label><br/>
113         <select id="fruit" name="fruit" title="Please select at least two fruits" validate="required:true, minlength:2" multiple="multiple">
114             <option value="b">Banana</option>
115             <option value="a">Apple</option>
116             <option value="p">Peach</option>
117             <option value="t">Turtle</option>
118         </select>
119     </p>
120     
121     <p>
122         <label for="vegetables">Please select no more than two vergetables</label><br/>
123         <select id="vegetables" name="vegetables" title="Please select no more than two vergetables" validate="required:true, maxlength:2" multiple="multiple">
124             <option value="p">Potato</option>
125             <option value="t">Tomato</option>
126             <option value="s">Salad</option>
127         </select>
128     </p>
129     
130     <p>
131         <label for="cars">Please select at least two cars, but no more than three</label><br/>
132         <select id="cars" name="cars" title="Please select at least two cars, but no more than three" validate="required:true, rangelength:[2,3]" multiple="multiple">
133             <option value="m_sl">Mercedes SL</option>
134             <option value="o_c">Opel Corsa</option>
135             <option value="vw_p">VW Polo</option>
136             <option value="t_s">Titanic Skoda</option>
137         </select>
138     </p>
139     
140     <p><input type="submit" value="Validate Selecttests"/></p>
141 </form>
142
143 <a href="index.html">Back to main page</a>
144
145 </div>
146
147
148 </body>
149 </html>