Discover answers to your questions with Westonci.ca, the leading Q&A platform that connects you with knowledgeable experts. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform. Get quick and reliable solutions to your questions from a community of experienced experts on our platform.
Sagot :
Answer:
Explanation:
The code provided had many errors. I fixed the errors and changed the userAgeCheck function as requested. Checking the age of that the user has passed as an input and changing the variables as needed depending on the age. The background color that was changed was for the form field as the question was not very specific on which field needed to be changed. The piece of the code that was created can be seen in the attached image below.
var validColor = "LightGreen";
var invalidColor = "Orange";
var userAgeInput = document.getElementById("userAge");
var formWidget = document.getElementById("userForm");
var userAgeValid = false;
function userAgeCheck(event) {
if ((userAgeInput >= 25) && (userAgeInput <= 35)) {
document.getElementById("userForm").style.backgroundColor = validColor;
userAgeValid = true;
} else {
document.getElementById("userForm").style.backgroundColor = invalidColor;
userAgeValid = false;
}
};
function formCheck(event) {};
if (!userAgeValid) {
userAgeInput.addEventListener("input", userAgeCheck);
formWidget.addEventListener('submit', formCheck);
event.preventDefault();
}

Thank you for choosing our service. We're dedicated to providing the best answers for all your questions. Visit us again. Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Get the answers you need at Westonci.ca. Stay informed with our latest expert advice.