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]
3 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]3 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
Which operating system became obsolete with the arrival of a more advanced graphical user interfaces
12345 [234]
The answer is Ms Dos
6 0
4 years ago
50 POINTS! What can be viewed in the Tasks folder? Check all that apply.
Rom4ik [11]

1, 2, and 4 :))) good luck

6 0
3 years ago
Read 2 more answers
Transmits data as pulses of light through tiny tubes of glass Uses standard telephone lines to create a high-speed connection Co
defon

Answer:

The answer is "True".

Explanation:

To transfer data, the fiber optic wire used a high-speed data transmission medium, which includes a small glass or plastic polymers, that carry the light beam to transmit data through swift light flashes through the cable.

  • It enables the transmission of data more quickly over larger distances.
  • In this cable, the traditional cable use to provide web data transfer to cable TV, that why the given statement is true.
4 0
3 years ago
Match the vocabulary to the appropriate definition.
Allisa [31]

Answer:

Pulling related code together in objects is Arrays

Helps programmers when they revisit code or are new to code-- Documentation

Explanation:

This is all I know

3 0
2 years ago
Can some give me engineers names that start with the letter A-Z
Nadya [2.5K]

Answer:

elon musk/ bill gates/ jeff bezos/ henry ford/ tim cook

Explanation:

i googled it/ i added more

6 0
3 years ago
Other questions:
  • A bit shift is a procedure whereby the bits in a bit string are moved to the left or to the right. For example, we can shift the
    12·1 answer
  • If you think the user might enter 24.9, you should create a float variable. true or false
    9·1 answer
  • Write the definition of a method printarray, which has one parameter , an array of int s. the method does not return a value . t
    10·1 answer
  • Why is it important to cite your sources?
    8·2 answers
  • How many times will line 7 be executed when the following code is run?
    5·1 answer
  • For a business that is properly using a social media information system, the system can
    13·1 answer
  • The complete process for learning through repetition is to read, write, say, rest and revisit the information. Please select the
    12·2 answers
  • ________ is the use of information technology to support the sharing of content among networks of users.
    14·1 answer
  • (C) Describe about the different types of computer<br> peripherals and memory devices.
    9·1 answer
  • Determine which system you would recommend each of the customers use based on their provided user and system specs.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!