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