-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform1.html
More file actions
49 lines (48 loc) · 1.54 KB
/
form1.html
File metadata and controls
49 lines (48 loc) · 1.54 KB
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
<!--A form with client-side validation added & no data is sent to backend
br/ - is used for line breaks-->
<!DOCTYPE html>
<html>
<head>
<title>form1</title>
</head>
<body>
<form>
Email: <input name="email" type="text"/>
<br/>
Password: <input name="password" type="password"/>
<br/>
Password(again): <input name="confirmation" type="password"/>
<br/>
I agree to the Terms & Conditions: <input name="agreement" type="checkbox"/>
<br/><br/>
<input type="submit" value="Register"/>
</form>
<script>
var form = document.getElementById('form');
form.onsubmit = function()
{
if (form.email.value == '')
{
alert('You must provide email address');
return false;
}
else if (form.password.value == '')
{
alert ('You must provide password');
return false;
}
else if (form.password.value != form.confirmation.value)
{
alert('Passwords do not match');
return false;
}
else if (!form.agreement.checked)
{
alert('You must agree to Terms & Conditions!');
return false;
}
return false;
};
</script>
</body>
</html>