Ask 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 userAgeValid. Otherwise, set the background to Orange and userAgeValid to false.

+5
Answers (1)
  1. 7 March, 01:28
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers