"jquery validation"
Bootstrap 3.0.0 Snippet by quaisar

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
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="row">
<h2>Jquery validation</h2>
<form id="register-form">
<fieldset>
<legend>Sign up for a business account</legend>
</fieldset>
<p>Create a login</p>
<div class="form-group col-md-12">
<input class="form-control" name="email" placeholder="Email address" type="email">
</div>
<div class="form-group col-md-6">
<input class="form-control" name="password" id="password" placeholder="Password" type="password">
</div>
<div class="form-group col-md-6">
<input class="form-control" name="password2" placeholder="Re-enter password" type="password">
</div>
<div class="clearfix">
</div>
<p>Tell us about your business</p>
<div class="form-group col-md-6">
<input class="form-control" name="firstName" placeholder="First name" type="text">
</div>
<div class="form-group col-md-6">
<input class="form-control" name="secondName" placeholder="Last name" type="text">
</div>
<div class="form-group col-md-12">
<input class="form-control" name="businessName" placeholder="Business name" type="text">
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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
$(function() {
$.validator.setDefaults({
errorClass: 'help-block',
highlight: function(element) {
$(element)
.closest('.form-group')
.addClass('has-error');
},
unhighlight: function(element) {
$(element)
.closest('.form-group')
.removeClass('has-error');
},
errorPlacement: function (error, element) {
if (element.prop('type') === 'checkbox') {
error.insertAfter(element.parent());
} else {
error.insertAfter(element);
}
}
});
$.validator.addMethod('strongPassword', function(value, element) {
return this.optional(element)
|| value.length >= 6
&& /\d/.test(value)
&& /[a-z]/i.test(value);
}, 'Your password must be at least 6 characters long and contain at least one number and one char\'.')
$("#register-form").validate({
rules: {
email: {
required: true,
email: true,
remote: "http://localhost:3000/inputValidator"
},
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: