Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help! (Code for first_loop.htm is at the end) Modify the file first_loop.htm so that there is a second text field asking the user how

Please help! (Code for first_loop.htm is at the end)

Modify the file first_loop.htm so that there is a second text field asking the user how many times they want to be greeted, stipulating that it must be between 1 and 20. Then greet them that many times.

Validation: Confirm that value was indeed between 1 and 20. If it is not, output a message reminding them that they must enter a value between 1 and 20, and then do not continue with the function (make the function end). Hint: Remember that a 'return' staement will a function.

If the user enters invalid input, then output the appropriate message (e.g. "You must enter a number between 1 and 20") to a div section called 'errors'. Also set the background color of the invalid text field to yellow.

Note: Each time the user clicks the button, you should remove any output from a previous run of the program. If any errors are present, you should remove any error messages, and remove the yellow background from the text field (by setting the background color to white).

Using regular expressions, make sure that the value entered by the user only contains digits. I will also give you a few hints here:

1.You will want to do this BEFORE invoking parseInt on the number.

2.The regular expression character: will match anything that is not a digit. So if you search for this character and get a -1, it means that all characters in the string aredigits. However, if you do NOT get a -1, it means there are non-numeric characters present.

3.Once you have confnirmed that the numbers are indeed only digits, THEN proceed to the part wher you check that the number is between 1 and 20, etc.

First Loop

Type in your name and I will greet you 3 times!


Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inference Control In Statistical Databases From Theory To Practice Lncs 2316

Authors: Josep Domingo-Ferrer

2002nd Edition

3540436146, 978-3540436140

More Books

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago