1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
o-na [289]
4 years ago
5

You have been asked to write a username validation program for a small website. The website has specific rules on what constitut

es a valid username, including:
All usernames must be between 8 and 15 characters long

Usernames can only contain alphabetic (a-z and A-Z) and numeric characters (0-9) - no special characters are allowed.

The first character in a username cannot be a digit

Usernames must contain at least one uppercase character

Usernames must contain at least one lowercase character

Usernames must contain at least one numeric character

Write a program that asks the user to enter in a username and then examines that username to make sure it complies with the rules above. Here's a sample running of the program - note that you want to keep prompting the user until they supply you with a valid username:

Please enter a username: foo
Username must be between 8 and 15 characters.

Please enter a username: fooooooooooooooooooo
Username must be between 8 and 15 characters.

Please enter a username: foo ooo ooo
Username must contain only alphanumeric characters.

Please enter a username: foooooooooo
Your username must contain at least one digit

Please enter a username: 1fooooooooo
The first character in your username cannot be a digit

Please enter a username: fooooooooo1
Your username must contain at least one uppercase character

Please enter a username: Fooooooooo1
Your username is valid!
Computers and Technology
1 answer:
vazorg [7]4 years ago
5 0

Answer:

var username;           // username entered by user

var charAny;            // text character identified in username

var anyNum = false;     // digit variable used to detect whether the username has one or not

var index;              // index loop variable

var BR = "<br />";      //break

var ES = "";            //space

// Display program requirements for the username requested

document.write("We'll begin helping you select a username" + BR);

document.write("Your username must have at least 8 characters," + BR);

document.write("   start with a letter, and contain at least 1 numeric character." + BR);

username = prompt("Please enter your username: ", ES);

// Check for length of username

while (username.length < 8) {

   document.write("Your username must be at least 8 characters long." + BR);

   username = prompt("Please enter your username: ", ES);

}

// Check that first character is a letter

// Substring function has three arguments: string, starting position, and ending position

charAny = username.substr(0, 1);

while (charAny !== isLetter()) {

   document.write("The first character of your username must be a letter." + BR);

   username = prompt("Please enter your username: ", ES);

}

// Check that there's at least one digit in the username

while (anyNum !== false) {

// Check each character, set anyNum to true if a digit

   for (index = 1; index < username.substr(index, index); index++) {

       anyNum = username.substr(index, index);

       if (isNumeric(charAny)) {

           anyNum = true;

       }

   }

   // If anyNum is false there were no numerics

   if (anyNum !== true) {

       document.write("Your username must include at least 1 digit." + BR);

       username = prompt("Please enter your username: ", ES);

   }

}

You might be interested in
When a startup failure occurs before the logon user interface appears, the problem could be hardware-related but it is most like
blondinia [14]

Answer: by using the safe mode

Explanation: to start the computer using the safe mode immediately after the computer is powered on or restarted (usually after you hear your computer beep), tap the F8 key in 1 second intervals.

5 0
4 years ago
What is the output of this program?
irinina [24]

Answer:

Output: yes

Explanation:

First if statement is satisfied, since numA==2, so yes is printed.

The elif statement is skipped altogether, since elif statements are only evaluated, when the statement above if false, which it is not.

8 0
3 years ago
Naruto Uzumaki who likes naruto ??? who waches it??
nika2105 [10]

Answer:

me

Explanation:

naruto is the coolest dude

6 0
3 years ago
Read 2 more answers
Theo would like to apply formatting to record data based on values in comparison with values in other fields. Which option shoul
poizon [28]

Answer:

Conditional Formatting

Explanation:

A database management system (DBMS) can be defined as a collection of software applications that typically enables computer users to create, store, modify, retrieve and manage data or informations in a database. Generally, it allows computer users to efficiently retrieve and manage their data with an appropriate level of security.

A data dictionary can be defined as a centralized collection of information on a specific data such as attributes, names, fields and definitions that are being used in a computer database system.

In a data dictionary, data elements are combined into records, which are meaningful combinations of data elements that are included in data flows or retained in data stores.

This ultimately implies that, a data dictionary found in a computer database system typically contains the records about all the data elements (objects) such as data relationships with other elements, ownership, type, size, primary keys etc. These records are stored and communicated to other data when required or needed.

Conditional formatting is a feature found in a lot of spreadsheet software applications such as Microsoft Excel and it avails end users the ability to apply specific formatting options to cells based on certain defined criteria.

Basically, it is used for highlighting, emphasize, comparing or differentiating between data (information) stored in a spreadsheet document i.e data values that are lesser than or greater than a specificied value.

In this scenario, Theo would like to apply formatting to record data based on values in comparison with values in other fields. Thus, the option he should use is conditional formatting.

7 0
3 years ago
Read 2 more answers
6. Which of the following menu commands would you select to make a copy of an open file and rename it?
nadya68 [22]
"Save as" command allows you to save a copy of an open file and rename it whatever you like.
8 0
3 years ago
Read 2 more answers
Other questions:
  • What is the curriculum of digital literacy
    6·1 answer
  • What is the keyboard command that allows you to copy text
    12·2 answers
  • A formula =A1+B2 is in cell D8. If you copy that formula to cell D9, what is the new formula in cell D9? A. '=A1+B2 B. '=A2+B3 C
    8·2 answers
  • A web ______ is a computer that delivers requested webpages to your computer or mobile device.
    7·1 answer
  • Ask what are brainly points for besides asking questions.
    9·1 answer
  • (ORAL COMMUNICATIONS)- I just need someone to please check if my answers are correct, and if not, please correct me :)
    8·1 answer
  • What program has unique drag and drop support functions?
    13·1 answer
  • Will give 5 star and mark brainleist
    14·1 answer
  • Which data type stores a single letter?
    5·1 answer
  • Please help!!!
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!