Repository navigation
Expand file tree
/
Copy pathchallenge3.html
More file actions
executable file
·69 lines (61 loc) · 1.81 KB
/
Copy pathchallenge3.html
File metadata and controls
executable file
·69 lines (61 loc) · 1.81 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Challenge 3</title>
<link href="https://fonts.googleapis.com/css?family=Allan" rel="stylesheet">
<style>
.errorMsg {
/*font: Use a cool Google font*/
color: red;
font-family: "Allan";
display: none;
}
</style>
<script>
function checkForm(){
console.log("Yeppers")
let name = document.querySelector("#name").value;
let addr = document.querySelector("#addr").value;
if (name == "") {
document.querySelector("#nameError").style.display = "block";
}
else {
document.querySelector("#nameError").style.display = "none";
}
if (addr == "") {
document.querySelector("#addressError").style.display = "block";
}
else {
document.querySelector("#addressError").style.display = "none";
}
if (name !== "" && addr !== "") {
console.log("Submit!");
return true;
}
else {
console.log("Don't Submit!");
return false;
}
//}
// Write a function that displays the appropriate error message(s) if a field is left blank. Make sure the form action is not performed if either field is blank.
}
</script>
</head>
<body>
<h1>Challenge 3</h1>
<form action="challenge4.html" onsubmit="return checkForm()">
<fieldset>
<legend>Personal details</legend>
<label for="name">Full name: </label>
<input type="text" name="fullname" id="name"><br/>
<p class="errorMsg" id="nameError">Please enter your name above!</p>
<label for ="streetaddr"></label>
Street Address:
<input type="text" name="addr" id="addr">
<p class="errorMsg" id="addressError">Please enter your street address!</p>
</fieldset>
<input type="submit" value="Submit it!">
</form>
</body>
</html>