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]
4 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]4 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
15 points: Which type of system is used to capture and leverage the decision-making abilities of human experts?
salantis [7]

Answer:

A

Explanation:

4 0
3 years ago
Given the variables costOfBusRental and maxBusRiders of type int , write an expression corresponding to the cost per rider (assu
Liono4ka [1.6K]

Answer:

       int costOfBusRental;

       int maxBusRiders;

       int costPerRider;

       costPerRider = costOfBusRental/maxBusRiders;

Explanation:

The costPerRider is the total cost of renting the bus (costofBusRental) divided by all the bus users (maxBusRiders). So we declare the three variables to be of type int as required by the question.

7 0
4 years ago
Chất xơ có nhiều trong thực phẩm nào?
mezya [45]

Answer: rau củ quả đều có lượng chất xơ nhiều hơn so với các loại thực phẩn khác

Explanation:

3 0
3 years ago
30 POINTS!!
bulgar [2K]

Answer:

online

the answer is online

7 0
3 years ago
Write a do - while loop to get 20 numbers from the user and sum them together. output the sum after the loop. declare any variab
Lilit [14]
A do while loop in this situation is actually stupid. A for loop or while loop will suit this purpose better, since you do not need to make sure it executes at least once for the given condition. Do while loops are good for situations where the condition may not be true initially, and you'd like to guarantee execution at least once. E.g circular linked list node counter.
8 0
3 years ago
Other questions:
  • What is the property of the Magnetic Lasso tool?
    6·2 answers
  • This is not school related in anyway but. I used to play this videogame on my computer years ago, but i cannot remember the name
    13·2 answers
  • A c++ member function that uses, but does not change, the value of a member variable is called
    13·1 answer
  • I need help answering these questions!
    11·1 answer
  • Which of the following for-loop headers results in equivalent numbers of iterations: A. for (int q = 1; q &lt;= 100; q++) B. for
    12·1 answer
  • What happens if i unplug my alarm system?
    11·1 answer
  • The ________ function reads a piece of data that has been entered at the keyboard and returns that piece of data, as a string, b
    15·2 answers
  • Complete the sentence with the correct response.
    9·1 answer
  • How to run angular project from github.
    7·1 answer
  • A file extension of. Xlsm indicates what type of workbook.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!