Training Guide: Programming in HTML5 with JavaScript and CSS3 Ebook

(Nora) #1

Practice exercises CHAPTER 7 335


Figure 7-10 shows the ContactUs.html page. When you see the QueryString, it means
that the Submit button worked. Currently, the data isn’t being processed at a server.
That will come in the next chapter. For now, you want to limit the ability of the Submit
button so it doesn’t operate until data is entered in all fields.

FIGURE 7-10 he ContactUs.html pageT

Exercise 2: Add validation to the Contact Us form


In this exercise, you continue with the project from Exercise 1 and modify the ContactUs.html
file to clean up the webpage and add validation to it.


  1. Open the project from Exercise 1.
    If you didn’t perform Exercise 1, you can use the project located in the Exercise 2 Start
    folder.

  2. Open the ContactUs.html file.

  3. Add the required attribute to the firstName, lastName, email, and message fields.

  4. Replace the type attribute on the email field with type=”email”, which will provide
    added validation of the email address.

  5. Change the message to a