Skip to content

Commit

Permalink
stylefix: remove '.border-danger' during form reset
Browse files Browse the repository at this point in the history
  • Loading branch information
logic-fabric committed Feb 1, 2021
1 parent c1646bb commit 16a5160
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ <h1 class="l-hero__heading lg10 md10 sm12">
id="first-name"
name="first-name"
minlength="2"
maxlength="63"
required
/>
<p class="c-modal__form-error" aria-live="polite"></p>
Expand All @@ -138,6 +139,7 @@ <h1 class="l-hero__heading lg10 md10 sm12">
id="last-name"
name="last-name"
minlength="2"
maxlength="63"
required
/>
<p class="c-modal__form-error" aria-live="polite"></p>
Expand Down
7 changes: 6 additions & 1 deletion js/components/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ const displaySuccessfullSignin = () => {
modalSuccessWrapper.style.height = modalHeight;
};

const removeAllErrors = () => {
export const removeAllErrors = () => {
const errorFields = [
firstNameError,
lastNameError,
Expand All @@ -257,9 +257,14 @@ const removeAllErrors = () => {
locationError,
generalConditionsOptinError,
];
const inputFields = document.querySelectorAll("input");

for (const errorField of errorFields) {
errorField.textContent = "";
errorField.classList.remove("txt-danger");
}

for (let inputField of inputFields) {
inputField.classList.remove("border-danger");
}
};
3 changes: 3 additions & 0 deletions js/components/modal.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { removeAllErrors } from "./form.js";

const modalBackground = document.getElementById("modal-bg");
const modalWindow = document.getElementById("modal-window");
const modalFormWrapper = document.getElementById("modal-form-wrapper");
Expand All @@ -18,6 +20,7 @@ document.getElementById("close-modal-btn").onclick = closeModal;

function openModal() {
document.getElementById("modal-form").reset();
removeAllErrors();

modalFormWrapper.style.height = "auto";
modalSuccessWrapper.style.height = 0;
Expand Down

0 comments on commit 16a5160

Please sign in to comment.