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
A research team is studying parallel computing. They want to run parallel process without having to use multiple processors. How
aleksandr82 [10.1K]
I wanna say threads bc cores r processors. And one can run multiple threads. Double check tht :)
5 0
4 years ago
A company is looking for an employee to assign passwords to all of its
d1i1m1o1n [39]

Answer:

B. Information security analysis.

Explanation:

8 0
2 years ago
To control how and when the slides should appear during the slide show, we use the__________________ feature​
jekas [21]

Answer:

Slide transition

Explanation:

See open chapter 4 page 49 and you will get it

8 0
3 years ago
What are the primary functions of motor oil? a. Reduce friction and prevent wear b. Keep engine surfaces clean c. Remove heat to
ryzh [129]

The answer is E: all of the above.

7 0
3 years ago
Which statements describe the Styles gallery? Check all that apply.
Komok [63]

Which statements describe the Styles gallery? Check all that apply.

It has many different style samples that can be applied.A user has to hit Shift+F1 to see it.A user has to hit Insert to see it.It is found under the Home tab.<span>A user can save custom styles to be used in the future.</span>
4 0
4 years ago
Read 2 more answers
Other questions:
  • The counter variable in the code below increments by 1 each time through the loop. What will the value of counter be after the f
    11·1 answer
  • Fundamental types of data, such as strings, integers, and real numbers, are known as
    5·1 answer
  • While in slide show mode, if you are not careful you can close the application by clicking the x on the menu bar. question 38 op
    12·2 answers
  • What is a social media networks
    5·1 answer
  • What are the different between Facebook and LinkedIn
    15·2 answers
  • Name some technologies that engineers create
    13·1 answer
  • From the following list choose all the tasks an operating system performs.
    5·2 answers
  • Which statement about routers is !!!FALSE!!!
    10·1 answer
  • I need help pls help me
    8·1 answer
  • There are many ways you can improve the performance of a website from an SEO perspective. When it comes to link building, which
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!