-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
52 lines (43 loc) · 1.34 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
<html>
<head>
<title>Simple Javascript Validator</title>
<script src="simple-javascript-validator.js" type="text/javascript"></script>
</head>
<body>
<form name="form_main" onsubmit="return validateForm();">
Name : <input id="name" /><br/>
Age : <input id="age" /><br/>
Birthday : <input id="birthday" /><br/>
Email : <input id="email_address" /><br/>
Role : <select id="role">
<option value="0" selected="selected">- select -</option>
<option value="1">Admin</option>
<option value="2">Guest</option>
</select>
<button>Save</button>
</form>
<script>
function validateForm()
{
var full_name = document.getElementById("name").value;
var age = document.getElementById("age").value;
var birthdate = document.getElementById("birthday").value;
var email_address = document.getElementById("email_address").value;
var role = document.getElementById("role").value;
var validateData = {
name : full_name + '|required',
age : age + '|required,number',
birthday : birthdate + '|required,date',
email : email_address + '|required,email',
role : role + '|gtzero'
};
var errors = validateInputs(validateData);
if(errors){
console.log(errors);
//toastr['error'](errors);
return false;
}
}
</script>
</body>
</html>