Skip to content

Commit adba42c

Browse files
committed
remove solutions
1 parent 36e8421 commit adba42c

File tree

4 files changed

+4
-76
lines changed

4 files changed

+4
-76
lines changed

dom-manipulation/exercise/script.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,3 @@ const countries = [
6969
// Use a li to display the country.
7070
// Add an img to each country to display the flag of each country.
7171
// Append each country to the correct part of the DOM (e.g., Germany should be added to the Europe list since it's part of Europe, whereas Japan should be added to Asia)
72-
73-
const asiaList = document.querySelector(".asia");
74-
const europeList = document.querySelector(".europe");
75-
76-
for (let i = 0; i < countries.length; i++) {
77-
const country = countries[i];
78-
const countryListItem = document.createElement("li");
79-
const countryName = document.createTextNode(
80-
`${country.name} (${country.code})`
81-
);
82-
const countryFlagImage = document.createElement("img");
83-
countryFlagImage.setAttribute("src", country.flagImageUrl);
84-
85-
countryListItem.appendChild(countryName);
86-
countryListItem.appendChild(countryFlagImage);
87-
88-
(country.region === "Asia" ? asiaList : europeList).appendChild(
89-
countryListItem
90-
);
91-
}

event-handling/exercise/script.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,3 @@
44
55
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset
66
*/
7-
8-
const container = document.querySelector(".container");
9-
10-
function handleButtonClick(event) {
11-
container.style.backgroundColor = event.target.dataset.color;
12-
}
13-
14-
container.addEventListener("click", handleButtonClick);

forms/index.html

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,7 @@ <h1>Conference Signup Form</h1>
7272
<div class="signup-form-row">
7373
<div>
7474
<label for="email">E-mail address:</label>
75-
<input
76-
type="email"
77-
id="email"
78-
name="email"
79-
required
80-
minlength="6"
81-
/>
82-
<span class="error" aria-live="polite"></span>
75+
<input type="email" id="email" name="email" />
8376
</div>
8477
</div>
8578

@@ -142,7 +135,7 @@ <h1>Conference Signup Form</h1>
142135

143136
<div class="signup-form-row">
144137
<label for="topic">Topic</label>
145-
<select name="topic" id="topic" required>
138+
<select name="topic" id="topic">
146139
<option value="">Select One</option>
147140
<optgroup label="Cryptocurrency">
148141
<option value="bitcoin">Bitcoin</option>
@@ -155,7 +148,6 @@ <h1>Conference Signup Form</h1>
155148
<option value="fullstack">Fullstack</option>
156149
</optgroup>
157150
</select>
158-
<span class="error" aria-live="polite"></span>
159151
</div>
160152

161153
<div class="signup-form-row">

forms/script.js

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,12 @@
2020
const signupForm = document.querySelector(".signup-form");
2121

2222
const addressInput = document.querySelector("#address-line-1");
23-
const topicSelect = document.querySelector("#topic");
2423
const otherInterestsTextArea = document.querySelector("#other-interests");
25-
const emailInput = document.querySelector("#email");
2624

2725
const addressError = document.querySelector("#address-line-1 + span.error");
28-
const topicError = document.querySelector("#topic + span.error");
2926
const otherInterestsError = document.querySelector(
3027
"#other-interests + span.error"
3128
);
32-
const emailError = document.querySelector("#email + span.error");
3329

3430
/**
3531
EVENT HANDLERS
@@ -38,16 +34,9 @@ function handleSignupFormSubmit(event) {
3834
event.preventDefault();
3935

4036
!addressInput.validity.valid && handleAddressInput();
41-
!topicSelect.validity.valid && handleTopicSelectInput();
42-
!emailInput.validity.valid && handleEmailInput();
4337
!otherInterestsTextArea.validity.valid && handleOtherInterestsTextAreaInput();
4438

45-
if (
46-
addressInput.validity.valid &&
47-
topicSelect.validity.valid &&
48-
otherInterestsTextArea.validity.valid &&
49-
emailInput.validity.valid
50-
) {
39+
if (addressInput.validity.valid && otherInterestsTextArea.validity.valid) {
5140
// send form data
5241
}
5342
}
@@ -60,13 +49,7 @@ function handleAddressInput() {
6049
: "";
6150
}
6251

63-
// Use JavaScript to display an error message "You must select a topic" below to the
64-
// Topic dropdown menu if the option selected is "Select One"
65-
function handleTopicSelectInput() {
66-
topicError.textContent = topicSelect.validity.valueMissing
67-
? "You must select a topic"
68-
: "";
69-
}
52+
// EXERCISE 1: Use JavaScript to display an error message "You must select a topic" below to the Topic dropdown menu if the option selected is "Select One"
7053

7154
// Use JavaScript to display an error message below the text area if the content is
7255
// less than 10 characters long when the user submits the form. Your error message
@@ -103,30 +86,11 @@ function handleOtherInterestsTextAreaInput(event) {
10386
- If the provided input is too short, display the following error message: "Email should be at least 6 characters but you entered {X} characters."
10487
- Perform the validation as the user is typing into the input field (meaning you should use the "input" event), as well as, when the user submits the form.
10588
*/
106-
function handleEmailInput() {
107-
const emailValidity = emailInput.validity;
108-
109-
if (emailValidity.valid) {
110-
emailError.textContent = "";
111-
emailError.classList.add("error");
112-
} else {
113-
if (emailValidity.valueMissing) {
114-
emailError.textContent = "You need to provide an e-mail address.";
115-
} else if (emailValidity.typeMismatch) {
116-
emailError.textContent = "Please enter a valid e-mail address.";
117-
} else if (emailValidity.tooShort) {
118-
emailError.textContent = `Email should be at least ${emailInput.minLength} characters but you entered ${emailInput.value.length}.`;
119-
}
120-
emailError.classList.add(["error", "active"]);
121-
}
122-
}
12389

12490
/**
12591
REGISTER EVENT LISTENERS
12692
*/
12793
addressInput.addEventListener("input", handleAddressInput);
128-
emailInput.addEventListener("input", handleEmailInput);
129-
topicSelect.addEventListener("input", handleTopicSelectInput);
13094
otherInterestsTextArea.addEventListener(
13195
"input",
13296
handleOtherInterestsTextAreaInput

0 commit comments

Comments
 (0)