use-with-bootstrap.html
3.3 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Used With Bootstrap</title>
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
<style>
.n-bootstrap .msg-wrap {font-size: 14px; margin-top: 3px}
</style>
</head>
<body>
<div class="container" style="margin-top:30px">
<div class="col-md-5 col-md-offset-2">
<form id="form1" data-validator-option="{theme:'bootstrap', timely:2, stopOnError:true}">
<div class="form-group">
<label class="control-label">Username</label>
<input type="text" class="form-control" name="username"
data-rule="required;username;"
data-rule-username="[/[\w\d]{4,30}/, 'Please enter 3-12 digits, letters, underscores']"
data-tip="You can use letters, numbers and periods"
>
</div>
<div class="form-group">
<label class="control-label">Password</label>
<input type="password" class="form-control" name="pwd"
data-rule="Password: required; length(8~16)"
data-tip="Please fill in at least eight characters"
>
</div>
<div class="form-group">
<label class="control-label">Verify Password</label>
<input type="password" class="form-control" name="pwdAgain" data-rule="Verify Password: required; match(pwd)">
</div>
<div class="form-group">
<label class="control-label">Gender</label>
<select class="form-control" name="gender" data-rule="required">
<option value="">select ...</option>
<option value="1">Male</option>
<option value="2">Female</option>
<option value="3">Other</option>
</select>
</div>
<div class="form-group">
<label class="control-label">Email</label>
<input type="text" class="form-control" name="email" data-rule="required;email">
</div>
<div class="form-group">
<label class="control-label">Interest</label>
<div class="">
<label class="checkbox-inline"><input type="checkbox" name="interest" data-rule="checked">sports</label>
<label class="checkbox-inline"><input type="checkbox" name="interest">movie</label>
<label class="checkbox-inline"><input type="checkbox" name="interest">game</label>
</div>
</div>
<div class="form-group">
<label class="control-label">Note</label>
<textarea class="form-control" data-rule="required;"></textarea>
</div>
<div class="form-group">
<label class="checkbox-inline"><input type="checkbox" id="agree_arguments" data-rule="checked">I agree to the service agreement.</label>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="reset" class="btn btn-default">reset</button>
</div>
</form>
</div>
</div>
<script src="https://cdn.jsdelivr.net/jquery/1.12.3/jquery.min.js"></script>
<script src="../dist/jquery.validator.js?local=en"></script>
<script>
$(function(){
// Custom theme
$.validator.setTheme('bootstrap', {
validClass: 'has-success',
invalidClass: 'has-error',
bindClassTo: '.form-group',
formClass: 'n-default n-bootstrap',
msgClass: 'n-right'
});
});
</script>
</body>
</html>