Ask Question
8 May, 02:19

Validate that the user age field is between 18 and 100. If valid, set the background of the field to LightGreen and assign true to userAgeValid. Otherwise, set the background to Orange and userAgeValid to false.

+5
Answers (1)
  1. 8 May, 02:42
    0
    function userAgeCheck (event) {

    / / if age is in range 18 to 100

    / / parseInt () converts string into integer

    if (parseInt (userAge. value) > = 18 && parseInt (userAge. value) < = 100) {

    / / set color to light green

    document. body. style. backgroundColor = "green";

    userAgeValid = true;

    }

    else{

    / / set color to orange

    document. body. style. backgroundColor = "orange";

    userAgeValid = false;

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Validate that the user age field is between 18 and 100. If valid, set the background of the field to LightGreen and assign true to ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers