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
MaRussiya [10]
3 years ago
10

Fill the validateForm function to check that the phone number contains a number (use the isNaN function) and that the user name

is less than 11 characters long. Display "Phone number is invalid" and/or "User name is invalid" in the console log if the check does not pass. Use the preventDefault function to avoid submitting the form when the inputs are invalid.
Computers and Technology
1 answer:
son4ous [18]3 years ago
7 0

Answer:

Hi there! This question is asking to write a Javascript validation function to validate user input. Assuming the input fields have the id set as “phone_number” for the phone input, and “user_name” for the User’s name, we can write the function below to do the validation as required.

Explanation:

function validateForm() {

   if isNaN(document.getElementById(“phone_number”).value) {

       document.getElementById(“phone_number”).addClass(“error”)

       console.log(“Phone number is invalid”)

   }

   if document.getElementById(“user_name”).length < 11 {

       document.getElementById(“user_name”).addClass(“error”)

       console.log(“User name is invalid”)

   }

   document.getElementById(“submit”).addEventListener(“click”, function(e) {  

       if document.getElementById(“phone_number”).hasClass("error") || document.getElementById(“user_name”).hasClass(“error”)  {

           e.preventDefault();  

       }

   });

}

You might be interested in
The area of a square is stored in a double variable named area. write an expression whose value is length of the diagonal of the
cestrela7 [59]

Answer:

The correct answer to the following question will be "Math.sqrt(area*2)".

Explanation:

  • The Math.sqrt( ) method in JavaScript is used to find the squares root of the given figure provided to the feature as a variable.
  • Syntax Math.sqrt(value) Variables: this function takes a single variable value that represents the amount whose square root is to be determined.
  • The area of the figure is the number of squares needed to cover it entirely, like the tiles on the ground.

Area of the square = side times of the side.

Because each side of the square will be the same, the width of the square will only be one side.

Therefore, it would be the right answer.

5 0
3 years ago
What does ascii stand for?
tamaranim1 [39]
ASCII—American Standard Code for Information Interchange
7 0
3 years ago
Read 2 more answers
Which of the following programming languages
trapecia [35]

Answer:

I think

BASIC programming language

5 0
3 years ago
Read 2 more answers
Are our current copyright policies helping society or hurting society? i need help
Oksanka [162]

Answer:

helping society

Explanation:

it can help you to protect your works and creativity and brilliant ideas from liars and cheaters and frauds

5 0
3 years ago
Here's one just for fun . For all the car people on here !
Doss [256]

its B...... Dodge challenger SRT Demon


8 0
3 years ago
Read 2 more answers
Other questions:
  • What human activity would cause a decrease in the population of another species? (The action of humans would impact one species,
    9·1 answer
  • If the wrong server edition is installed, what command can be used to change to a different edition?​
    5·1 answer
  • Which of the following function declarations correctly expect an array as the first argument?
    12·1 answer
  • 0.005098 megaliters to liters. record your answer in whole liters
    7·1 answer
  • Provide a few examples of how cryptography actually secures data.
    8·1 answer
  • Write multiple if statements: If carYear is before 1967, print "Probably has few safety features." (without quotes). If after 19
    11·1 answer
  • What will happen to the tools and equipment, if it is not store propely?​
    7·1 answer
  • Select all the items of the Design Elements.
    7·1 answer
  • can you guys plz answeer this i need help rrly bad and plz no viruses or links or answers that have nun to do with this
    5·1 answer
  • In best practice, should you use all lowercase, all uppercase or a mixture of cases in HTML tag names?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!