Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a web page that will use a prompt box and ask a user to enter a valid user name. The entire user name will

Create a web page that will use a prompt box and ask a user to enter a valid user name. The entire user name will be accepted as a single String in the JavaScript code. A valid user name will contain at least 8 characters (test for length first). The first character must be a lower case letter of the alphabet (a - z), the second character must be an upper case letter of the alphabet (A-Z), and the last character must be a digit (0-9). Refer to pages 342 and 343 for pre-existing JavaScript string functions to help test for these conditions.

Some suggestions!!

length(username) - returns the length of the string - used in JavaScript code as username.length (see page 344)

use the statement firstchar = substring(username, 0, 1) - this returns to the variable firstchar the first character of the username

to test for A - Z use if statements to see if the char is >=A and <=Z

to test for a - z use if statements to see if the char is >=a and <=z

Test the last character with isNAN() - this function returns true if the character is NOT a number and false if it is a number OR test if the character is >=1 and <=9

Your JavaScript code will test for these conditions on the user entered string and indicate on the Web page if a valid user name was entered.

For 5 points of extra credit - give the user 3 chances to enter a correct user name. If after 3 chances, a correct user name is not entered then print a message on the Web page and end the script. Test your Web Page in a browser (preferably Google Chrome) to make sure it works.

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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

=+ 9. What is inflation and what causes it?

Answered: 1 week ago

Question

=+6. What does the invisible hand of the marketplace do?

Answered: 1 week ago