Skip to content

Commit c7c6217

Browse files
committed
Update demos: Basic cleanup, no more metadata. Fixes jquery-validation#708
1 parent 5da3085 commit c7c6217

File tree

4 files changed

+66
-228
lines changed

4 files changed

+66
-228
lines changed

demo/errorcontainer-demo.html

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
<!DOCTYPE html>
2-
<html xmlns="http://www.w3.org/1999/xhtml">
2+
<html lang="en">
33
<head>
4-
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
4+
<meta charset="utf-8">
55
<title>Test for jQuery validate() plugin</title>
66

7-
<link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />
7+
<link rel="stylesheet" media="screen" href="css/screen.css" />
88

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>
9+
<script src="../lib/jquery.js"></script>
10+
<script src="../jquery.validate.js"></script>
1211

13-
<style type="text/css">
12+
<style>
1413
.cmxform fieldset p.error label { color: red; }
1514
div.container {
1615
background-color: #eee;
@@ -34,7 +33,7 @@
3433
}
3534
</style>
3635

37-
<script type="text/javascript">
36+
<script>
3837
// only for demo purposes
3938
$.validator.setDefaults({
4039
submitHandler: function() {
@@ -46,16 +45,15 @@
4645
$("#form1").validate({
4746
errorLabelContainer: $("#form1 div.error")
4847
});
49-
48+
5049
var container = $('div.container');
5150
// validate the form when it is submitted
5251
var validator = $("#form2").validate({
5352
errorContainer: container,
5453
errorLabelContainer: $("ol", container),
55-
wrapper: 'li',
56-
meta: "validate"
54+
wrapper: 'li'
5755
});
58-
56+
5957
$(".cancel").click(function() {
6058
validator.resetForm();
6159
});
@@ -73,11 +71,11 @@ <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-vali
7371
<legend>Login Form</legend>
7472
<p>
7573
<label>Username</label>
76-
<input name="user" title="Please enter your username (at least 3 characters)" class="{required:true,minlength:3}" />
74+
<input name="user" title="Please enter your username (at least 3 characters)" required minlength="3">
7775
</p>
7876
<p>
7977
<label>Password</label>
80-
<input type="password" maxlength="12" name="password" title="Please enter your password, between 5 and 12 characters" class="{required:true,minlength:5}" />
78+
<input type="password" maxlength="12" name="password" title="Please enter your password, between 5 and 12 characters" required minlength="5">
8179
</p>
8280
<div class="error">
8381
</div>
@@ -104,11 +102,11 @@ <h4>There are serious errors in your form submission, please see below for detai
104102
<legend>Validating a complete form</legend>
105103
<p>
106104
<label for="email">Email</label>
107-
<input id="email" name="email" class="{validate:{required:true,email:true}}" />
105+
<input id="email" name="email" required type="email">
108106
</p>
109107
<p>
110108
<label for="agree">Favorite Color</label>
111-
<select id="color" name="color" title="Please select your favorite color!" class="{validate:{required:true}}">
109+
<select id="color" name="color" title="Please select your favorite color!" required>
112110
<option></option>
113111
<option>Red</option>
114112
<option>Blue</option>
@@ -117,23 +115,19 @@ <h4>There are serious errors in your form submission, please see below for detai
117115
</p>
118116
<p>
119117
<label for="phone">Phone</label>
120-
<input id="phone" name="phone" class="some styles {validate:{required:true,number:true, rangelength:[2,8]}}" />
118+
<input id="phone" name="phone" required type="number" rangelength="[2,8]">
121119
</p>
122120
<p>
123121
<label for="address">Address</label>
124-
<input id="address" name="address" class="some other styles {validate:{required:true,minlength:3}}" />
122+
<input id="address" name="address" required minlength="3">
125123
</p>
126124
<p>
127125
<label for="avatar">Avatar</label>
128-
<input type="file" id="avatar" name="avatar" class="{validate:{required:true,accept:true}}" />
126+
<input type="file" id="avatar" name="avatar" required>
129127
</p>
130128
<p>
131129
<label for="agree">Please agree to our policy</label>
132-
<input type="checkbox" class="checkbox" id="agree" title="Please agree to our policy!" name="agree" class="{validate:{required:true}}" />
133-
</p>
134-
<p>
135-
<label for="cv">CV</label>
136-
<input type="file" id="cv" name="cv" class="{validate:{required:true,accept:'docx?|txt|pdf'}}" />
130+
<input type="checkbox" class="checkbox" id="agree" title="Please agree to our policy!" name="agree" required>
137131
</p>
138132
<p>
139133
<input class="submit" type="submit" value="Submit"/>

demo/radio-checkbox-select-demo.html

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
11
<!DOCTYPE html>
2-
<html xmlns="http://www.w3.org/1999/xhtml">
2+
<html lang="en">
33
<head>
4-
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
4+
<meta charset="utf-8">
55
<title>Test for jQuery validate() plugin</title>
66

7-
<link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />
7+
<link rel="stylesheet" media="screen" href="css/screen.css">
88

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>
9+
<script src="../lib/jquery.js"></script>
10+
<script src="../jquery.validate.js"></script>
1211

13-
<script type="text/javascript">
12+
<script>
1413
// only for demo purposes
1514
$.validator.setDefaults({
1615
submitHandler: function() {
1716
alert("submitted!");
1817
}
1918
});
20-
21-
$.metadata.setType("attr", "validate");
2219

2320
$(document).ready(function() {
2421
$("#form1").validate();
2522
$("#selecttest").validate();
2623
});
2724
</script>
2825

29-
<style type="text/css">
26+
<style>
3027
.block { display: block; }
31-
form.cmxform label.error { display: none; }
28+
form.cmxform label.error { display: none; }
3229
</style>
3330

3431
</head>
@@ -43,101 +40,101 @@ <h1 id="banner"><a href="http://bassistance.de/jquery-plugins/jquery-plugin-vali
4340
<fieldset>
4441
<legend>Gender</legend>
4542
<label for="gender_male">
46-
<input type="radio" id="gender_male" value="m" name="gender" validate="required:true" />
43+
<input type="radio" id="gender_male" value="m" name="gender" required>
4744
Male
4845
</label>
4946
<label for="gender_female">
50-
<input type="radio" id="gender_female" value="f" name="gender"/>
47+
<input type="radio" id="gender_female" value="f" name="gender">
5148
Female
5249
</label>
5350
<label for="gender" class="error">Please select your gender</label>
5451
</fieldset>
5552
<fieldset>
5653
<legend>Family</legend>
5754
<label for="family_single">
58-
<input type="radio" id="family_single" value="s" name="family" validate="required:true" />
55+
<input type="radio" id="family_single" value="s" name="family" required>
5956
Single
6057
</label>
6158
<label for="family_married">
62-
<input type="radio" id="family_married" value="m" name="family" />
59+
<input type="radio" id="family_married" value="m" name="family">
6360
Married
6461
</label>
6562
<label for="family_other">
66-
<input type="radio" id="family_other" value="o" name="family" />
63+
<input type="radio" id="family_other" value="o" name="family">
6764
Other
6865
</label>
6966
<label for="family" class="error">Please select your family status.</label>
7067
</fieldset>
7168
<p>
7269
<label for="agree">Please agree to our policy</label>
73-
<input type="checkbox" class="checkbox" id="agree" name="agree" validate="required:true" />
74-
<br/>
70+
<input type="checkbox" class="checkbox" id="agree" name="agree" required>
71+
<br>
7572
<label for="agree" class="error block">Please agree to our policy!</label>
7673
</p>
7774
<fieldset>
7875
<legend>Spam</legend>
7976
<label for="spam_email">
80-
<input type="checkbox" class="checkbox" id="spam_email" value="email" name="spam[]" validate="required:true, minlength:2" />
77+
<input type="checkbox" class="checkbox" id="spam_email" value="email" name="spam[]" required minlength="2">
8178
Spam via E-Mail
8279
</label>
8380
<label for="spam_phone">
84-
<input type="checkbox" class="checkbox" id="spam_phone" value="phone" name="spam[]" />
81+
<input type="checkbox" class="checkbox" id="spam_phone" value="phone" name="spam[]">
8582
Spam via Phone
8683
</label>
8784
<label for="spam_mail">
88-
<input type="checkbox" class="checkbox" id="spam_mail" value="mail" name="spam[]" />
85+
<input type="checkbox" class="checkbox" id="spam_mail" value="mail" name="spam[]">
8986
Spam via Mail
9087
</label>
9188
<label for="spam[]" class="error">Please select at least two types of spam.</label>
9289
</fieldset>
9390
<p>
94-
<input class="submit" type="submit" value="Submit"/>
91+
<input class="submit" type="submit" value="Submit">
9592
</p>
9693
</fieldset>
9794
</form>
9895

9996
<form id="selecttest">
10097
<h2>Some tests with selects</h2>
10198
<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">
99+
<label for="jungle">Please select a jungle noun</label><br>
100+
<select id="jungle" name="jungle" title="Please select something!" required>
104101
<option value=""></option>
105102
<option value="1">Buga</option>
106103
<option value="2">Baga</option>
107104
<option value="3">Oi</option>
108105
</select>
109106
</p>
110-
107+
111108
<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">
109+
<label for="fruit">Please select at least two fruits</label><br>
110+
<select id="fruit" name="fruit" title="Please select at least two fruits" required minlength="2" multiple="multiple">
114111
<option value="b">Banana</option>
115112
<option value="a">Apple</option>
116113
<option value="p">Peach</option>
117114
<option value="t">Turtle</option>
118115
</select>
119116
</p>
120-
117+
121118
<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">
119+
<label for="vegetables">Please select no more than two vergetables</label><br>
120+
<select id="vegetables" name="vegetables" title="Please select no more than two vergetables" required maxlength="2" multiple="multiple">
124121
<option value="p">Potato</option>
125122
<option value="t">Tomato</option>
126123
<option value="s">Salad</option>
127124
</select>
128125
</p>
129-
126+
130127
<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">
128+
<label for="cars">Please select at least two cars, but no more than three</label><br>
129+
<select id="cars" name="cars" title="Please select at least two cars, but no more than three" required rangelength="[2,3]" multiple="multiple">
133130
<option value="m_sl">Mercedes SL</option>
134131
<option value="o_c">Opel Corsa</option>
135132
<option value="vw_p">VW Polo</option>
136133
<option value="t_s">Titanic Skoda</option>
137134
</select>
138135
</p>
139-
140-
<p><input type="submit" value="Validate Selecttests"/></p>
136+
137+
<p><input type="submit" value="Validate Selecttests"></p>
141138
</form>
142139

143140
<a href="index.html">Back to main page</a>

0 commit comments

Comments
 (0)