forked from AbhijitStack/JS_Validation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
90 lines (79 loc) · 2.55 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
<!DOCTYPE html>
<html>
<head>
<title>input field validation</title>
</head>
<body>
<div>
<form id="myform" action="success.html">
<label>File : </label>
<input id="file" type="file">
<br/><br/>
<label>Date : </label>
<input id="date" type="date">
<br/><br/>
<label>Name : </label>
<input id="name">
<br/><br/>
<label>Mobile : </label>
<input id="mobile">
<br/><br/>
<label>Email : </label>
<input id="email">
<br/><br/>
<label>Password : </label>
<input id="password" type="password">
<input id="repassword" type="password">
<br/><br/>
<label>Dropdown : </label>
<select id="dropdown">
<option value="null">select Option</option>
<option value="1">select Option 1</option>
<option value="2">select Option 2</option>
<option value="3">select Option 3</option>
<option value="4">select Option 4</option>
</select>
<br/><br/>
<label>Radio :</label>
<input id="radio" type="radio" name="rad1">
<input type="radio" name="rad1">
<input type="radio" name="rad1">
<br/><br/>
<label>Custom Field Validation : </label>
<input id="newField">
<br/><br/><br/>
<input type="submit">
</form>
</div>
<script src="js/validation.js"></script>
<script>
Validation.fields = [
{id: "newField", custom: "test"},
{id: "name", type: "name"},
{id: "password", maxlength: 10, minlength: 4, required: true, match: "repassword"},
{id: "date", required: true},
{id: "file", required: true},
{id: "email", type: "email", number: 5},
{id: "name", type: "name"},
{id: "mobile", type: "mobile"},
{id: "radio", type: "radio"},
{id: "dropdown", type: "dropdown"}
];
Validation.Initiate("myform");
function test() {
/*
Predefind elements:
------------------
Validation.element.id --- to get the id of the current field
Validation.element.value --- to get the value of the current field
Validation.message.add(" To add your custom message. ") --- Add your message block to that field.
*/
if (Validation.element.value != "123") {
Validation.message.add("Custom message block :Your id :" + Validation.element.id + " and Value should be '123'");
return false;
}
return true;
}
</script>
</body>
</html>