-
Notifications
You must be signed in to change notification settings - Fork 0
/
form_validation.html
51 lines (51 loc) · 1.79 KB
/
form_validation.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
<!DOCTYPE html>
<html>
<head>
<script type "application/javascript">
function checkdata()
{
//Create reference to the input elements
var username = document.getElementById("name");
var emailid = document.getElementById("email");
var varzipcode = document.getElementById("zipcode")
//check for missing entries
if(username.value==""){
window.alert("Please enter the name");
username.focus();
return false;
}
//check if email is empty
if(emailid.value==""){
window.alert("Please enter email address");
emailid.focus();
return false;
}
//check is zipcode is empty
if(zipcode.value==""){
window.alert("Please enter the zipcode");
varzipcode.focus();
return false;
}
return true;
}
</script>
<title>Contact Details</title>
</head>
<body>
<h2>Enter your contact Details:</h2><br>
<form id="form1" onsubmit="return checkdata()">
<label for="name">Name :</label>
<input type="text" id="name" name="name">
<br>
<br>
<label for="email">E-mail ID :</label>
<input type="email" id="email" name="email">
<br>
<br>
<label for=zipcode>zipcode</label>
<input type="number" id="zipcode" name="zipcode">
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>