-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformValidation.html
More file actions
38 lines (33 loc) · 1.01 KB
/
formValidation.html
File metadata and controls
38 lines (33 loc) · 1.01 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>form validation</title>
<script>
function validateForm() {
first = document.forms["FirstForm"]["FirstName"].value;
last = document.forms["FirstForm"]["LastName"].value;
if(first==null || first =="")
{
alert("Please input first name.")
return false
}
if(last==null || last =="")
{
alert("Please input last name.")
return false
}
else
{alert("Your name is: "+first+" "+last)}
}
</script>
</head>
<body>
<form name="FirstForm" onsubmit="return validateForm()" method="post">
Type your first name: <input type="text" name="FirstName" size="30" value=""> <br>
Type your last name: <input type="text" name="LastName" size="30"> <br>
<input type="submit" value="submit">
<input type="reset" value="reset">
</form>
</body>
</html>