-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
94 lines (83 loc) · 3.06 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
</head>
<body>
<form id="form">
<input name="user" value="user">
<input name="pass" value="password">
</form>
<input id="input">
<script src="./index.js"></script>
<script>
let val = new Validator(form);
let rules = {
pass: {
rules: 'required|min_length[6, 4]',
errors: {
required: 'password can not be missing!',
min_length: 'password must be greater than 6 chars'
}
},
user: {
rules: 'required|min_length[3]',
errors: {
required: 'username can not be missing!',
min_length: 'username must be greater than 3 chars'
}
},
school: {
rules: 'required|min_length[3]',
// errors: {
// required: 'username can not be missing!',
// min_length: 'username must be greater than 3 chars'
// }
},
age : {
rules: 'required'
}
}
let validation = val.validate(rules);
console.log(val.errors)
let my_form = new FormData();
my_form.append('login', 'username');
my_form.append('email', 'fritzdultimate@gmail.com');
my_form.append('number', '+23438222565');
my_form.append('password', 'fritz');
my_form.append('repass', 'fritz');
let rules_2 = {
login: {
rules: 'required|min_length[15]',
errors: {
required: 'Login form is empty'
}
},
email: {
rules: 'required|valid_email',
},
number: {
rules: 'required|min_length[6]|numeric',
errors: {
min_length: 'Mobile number is too short!',
}
},
password: {
rules: 'required|min_length[4]|max_length[45]'
},
repass: {
rules: 'matches[password]'
}
}
let val_2 = new Validator(my_form);
let validation_2 = val_2.validate(rules_2);
console.log(validation_2) // consoles false on error
console.log(val_2.errors)
</script>
</body>
</html>