-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
123 lines (109 loc) · 3.16 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Form validate js</title>
</head>
<body>
<form id="register_form" class="myForm" action="" method="post">
<div>
<label for="username">Username :*</label>
<input
type="text"
id="username"
name="username"
placeholder="Choose a username"
data-field-name="Username"
required
/>
</div>
<div>
<label for="email">Email :*</label>
<input
type="email"
id="email"
name="email"
placeholder="Your Email"
required
maxlength="30"
pattern="[A-Za-z]{3}"
title="Three letter country code"
/>
</div>
<div>
<label for="password">Password :*</label>
<input
type="password"
id="password"
name="password"
placeholder="Password"
autocomplete="off"
/>
</div>
<div>
<label for="confirm_password">Confirm Password :*</label>
<input
type="password"
id="confirm_password"
name="confirm_password"
placeholder="Password"
autocomplete="off"
/>
</div>
<div>
<label for="age">Age :*</label>
<input type="text" id="age" name="age" placeholder="Your Age" />
</div>
<div>
<label for="age">Languages :*</label>
<select id="languages" name="languages">
<option value="" selected>select language</option>
<option value="php">PHP</option>
<option value="javascript">JavaScript</option>
<option value="css3">CSS3</option>
</select>
</div>
<div>
<input type="radio" id="male" name="gender" value="male" />
<label for="male">Male</label><br />
<input type="radio" id="female" name="gender" value="female" />
<label for="female">Female</label><br />
</div>
<input type="submit" value="Register"/>
</form>
<script src="src/index.js"></script>
<script>
var validate = FormValidator('#register_form', {
events: ['change', 'input', 'submit'],
//lang: 'fr',
constraints: {
username: {
equal: '#password',
required: true,
match: 'username',
maxlength: function() {
// logic
return 30;
},
messages: {
/**
* three diffrent ways of altring the default error messages
*/
equal: function(msg) {
return this.format(msg, 'PASSWORD');
},
match: 'not matches {0} !!.',
required: function(msg) {
return 'Error : '+msg;
}
}
},
email: {} // the lib will depends on html5 validation attributes and input types
}
});
console.log(validate);
</script>
</body>
</html>