Ask Question
12 June, 09:28

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.

+1
Answers (1)
  1. 12 June, 11:21
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers