forked from sdeering/jquery-form-validation-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
190 lines (157 loc) · 5.12 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="keywords" content="basic jquery validation form demo" />
<script type="text/javascript" src="../js/jquery-1.6.4.js"></script>
<script type="text/javascript" src="../script.js"></script>
<script type="text/javascript" src="jquery.validate.min.js"></script>
<title>Basic jQuery Validation Form Demo | jQuery4u</title>
<link rel="stylesheet" type="text/css" href="../styles.css">
<style lang="text/css">
/* example styles for validation form demo */
#register-form {
background: url("form-fieldset.gif") repeat-x scroll left bottom #F8FDEF;
border: 1px solid #DFDCDC;
/*border-radius: 15px 15px 15px 15px;*/
display: inline-block;
margin-bottom: 30px;
margin-left: 20px;
margin-top: 10px;
padding: 25px 50px 10px;
width: 350px;
}
#register-form .fieldgroup {
background: url("form-divider.gif") repeat-x scroll left top transparent;
display: inline-block;
padding: 8px 10px;
width: 340px;
}
#register-form .fieldgroup label {
float: left;
padding: 15px 0 0;
text-align: right;
width: 110px;
}
#register-form .fieldgroup input, #register-form .fieldgroup textarea, #register-form .fieldgroup select {
float: right;
margin: 10px 0;
height: 35px;
width: 200px;
}
#register-form .submit {
color: gray;
padding: 10px;
width: 220px;
height: 40px !important;
}
#register-form .submit:hover {
color: #FFF;
}
#register-form .fieldgroup label.error {
color: #FB3A3A;
display: inline-block;
margin: 4px 0 5px 125px;
padding: 0;
text-align: left;
width: 220px;
}
h2 {
padding-bottom: 15px;
}
</style>
<script type="text/javascript">
/**
* Basic jQuery Validation Form Demo Code
* Copyright Sam Deering 2012
* Licence: http://www.jquery4u.com/license/
*/
(function($,W,D)
{
var JQUERY4U = {};
JQUERY4U.UTIL =
{
setupFormValidation: function()
{
//form validation rules
$("#register-form").validate({
rules: {
firstname: "required",
lastname: "required",
email: {
required: true,
email: true
},
password: {
required: true,
minlength: 5
},
agree: "required"
},
messages: {
firstname: "Please enter your firstname",
lastname: "Please enter your lastname",
password: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long"
},
email: "Please enter a valid email address",
agree: "Please accept our policy"
},
submitHandler: function(form) {
form.submit();
}
});
}
}
//when the dom has loaded setup form validation rules
$(D).ready(function($) {
JQUERY4U.UTIL.setupFormValidation();
});
})(jQuery, window, document);
</script>
</head>
<body>
<div id="page-wrap">
<div id="content">
<h1>Basic jQuery Validation Form Demo</h1>
<p class="padleft">This demo shows you how easy validation your forms can be using a little jQuery. It uses the jQuery validation plugin and some basic input validation rules. See the tutorial for details on how to setup your own validation in just a few minutes.</p>
<!-- HTML form for validation demo -->
<form action="" method="post" id="register-form" novalidate="novalidate">
<h2>User Registration</h2>
<div id="form-content">
<fieldset>
<div class="fieldgroup">
<label for="firstname">First Name</label>
<input type="text" name="firstname">
</div>
<div class="fieldgroup">
<label for="lastname">Last Name</label>
<input type="text" name="lastname">
</div>
<div class="fieldgroup">
<label for="email">Email</label>
<input type="text" name="email">
</div>
<div class="fieldgroup">
<label for="password">Password</label>
<input type="password" name="password">
</div>
<div class="fieldgroup">
<p class="right">By clicking register you agree to our policy.</p>
<input type="submit" value="Register" class="submit">
</div>
</fieldset>
</div>
<div class="fieldgroup">
<p>Already registered? Sign in.</p>
</div>
</form>
<!-- END HTML form for validation -->
<p>
<a class="seelivedemo" href="http://www.jquery4u.com/forms/basic-jquery-form-validation-tutorial/">Tutorial</a>
<a class="seelivedemo" href="http://www.jquery4u.com/demos/basic-jquery-validation-form/basic-jquery-validation-form-demo.zip">Download</a>
</p>
</div>
</div> <!-- end page wrap -->
</body>
</html>