I need help with Javascript. I need to validate that none of the fields (name, phone number, email, etc) are left blank upon the user clicking 'Submit' and I need to also validate that the phone number and email fields are valid formats.   The HTML:   Test TestingInputs       Home     About Us     Test           Contact Us                    Name:                Enter your name                  Email:                Enter an email                   Phone Number:                  Enter a phone number                   How can we help you?                  Tell us how we can help you                  Submit

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I need help with Javascript. I need to validate that none of the fields (name, phone number, email, etc) are left blank upon the user clicking 'Submit' and I need to also validate that the phone number and email fields are valid formats.

 

The HTML:

<!DOCTYPE html>

<html lang="en">

<meta charset="utf-8">

<link href="Something.css" rel="stylesheet">

 

<title>Test</title>



<body>

<header>

<h1>TestingInputs</h1>

</header>

<nav>

<ul>

 

    <li><a href="">Home</a></li>

    <li><a href="">About Us</a></li>

    <li><a href="">Test</a></li>

     </ul>

</nav>

 

<main>

 

<style>

    h2 {

        text-align: center;

        font-size: 40px;

    }

</style>

<h2>Contact Us</h2>

 

<section id="contact-input">

    <style>

        label {

            display: inline-block;

            width: 660px;

            text-align: right;

        }

    </style>

    <div>

       <label for="name">Name:</label>

       <input type="text" id="name">

       <span class="error-msg hidden" id="error-value-name">Enter your name</span>

    </div>

    <div>

       <label for="email">Email:</label>

       <input type="email" id="email">

       <span class="error-msg hidden" id="error-value-email">Enter an email</span>

    </div>

    <div>

        <label for="phone">Phone Number:</label>

        <input type="tel" id="phone">

        <span class="error-msg hidden" id="error-value-phone">Enter a phone number</span>

    </div>

    <div>

        <label for="help">How can we help you?</label>

        <input type="text" id="help" class="helpBox">

        <span class="error-msg hidden" id="error-value-help">Tell us how we can help you</span>

    </div>

    <div>

       <button id="submitBtn">Submit</button>

    </div>

</section>

</main>

</body>

</html>

Expert Solution
steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Knowledge Booster
JQuery and Javascript
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education