Design comparison
Solution retrospective
I am very proud that I was able to finish this design. It took me a while but I was also working on another project as well. For next time, I'd probably implement more semantic tags for readability purposes.
What challenges did you encounter, and how did you overcome them?One of the main challenges that I had was handling the logic for the input fields. Because I used type text, I couldnt just use checkValidity().
// Validate Mortgage Term
if (!mortgageTerm.value.trim() || isNaN(parseInt(termValue)) || termValue
### What specific areas of your project would you like help with?
clearBtn.addEventListener("click", () => {
// redefining due to scoping. Global placement didnt reference these variables
let amountError = document.querySelector(".amount-error");
let mortgageAmount = document.getElementById("mortgage-amount");
let poundSign = document.querySelector(".input-text-m");
let termError = document.querySelector(".error-term");
let mortgageTerm = document.getElementById("mortgage-term");
let yearSign = document.querySelector(".input-year");
let interestError = document.querySelector(".error-rate");
let interestField = document.getElementById("interest-rate");
let percentSign = document.querySelector(".input-percent");
let radioError = document.querySelector(".error-radio");
const resultDiv = document.querySelector(".result-container");
const resultPending = document.querySelector(".potential-results");
const monthPlan = document.querySelector(".month-plan");
const overTerm = document.querySelector(".over-term");
// referencing the form to clear it.
document.getElementById("mortgager").reset();
resultDiv.style.display = "none";
resultPending.style.display = "flex";
monthPlan.textContent = "";
overTerm.textContent = "";
amountError.style.display = "none";
mortgageAmount.classList.remove("error-input");
poundSign.classList.remove("error-span");
termError.style.display = "none";
mortgageTerm.classList.remove("error-input");
yearSign.classList.remove("error-span");
interestError.style.display = "none";
interestField.classList.remove("error-input");
percentSign.classList.remove("error-span");
radioError.style.display = "none";
document.getElementById("repayment").checked = false;
document.getElementById("interestO").checked = false;
});
If anyone has spare time, I need some assistance on how to **not** reference the inputs again when handling the clear button on all input fields. I tried putting all references inside of the global scope but then it started to affect the calculations for the main card. I referenced the variables again and it worked but I know this is not the most efficient thing to do.
Thank you for your time!
Community feedback
- @WarmarthPosted 21 days ago
you can use get the form element and use the reset() method to clear all the values
0 - @ChamuMutezvaPosted 21 days ago
Hi Clipzorama
You have already mentioned some of the issues that needs to be done, primarily using semantic html. Semantic is explained in MDN docs as
"what purpose or role does that HTML element have" (rather than "what does it look like?".)
. That is using an element that has meaning/purpose. When you use ap
element as abutton
element , it makes your site confusing to use for users and accessibility is affected. Keyboard users cannot be able to navigate through the page successfully. Landmark elements such as themain
are missing - usefull for structuring your webpage. A site should have themain
element as it identifies the primary content of the page.- Heading elements should follow a sequential order, from an
h2
heading element, you can skip to anh5
. The next heading element should have been anh3
. - a CSS reset stylesheet should be used to normalise your website, check for an modern css reset stylesheet
- font sizes should use
rem
values , this is best explained in the following article https://fedmentor.dev/posts/font-size-px/ - check your site between 601px and 850px , the display on the mentioned sizes does not look ok to me.
I did not check on the js, I haven't done mortgage calculations before . Hence I am not able to point if they are errors in the calculations
0 - Heading elements should follow a sequential order, from an
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord