Question: Project 2 In this project, youll use a conditional statement to check for browser support of the HTML5 placeholder feature, and execute code to replicate

Project 2 In this project, youll use a conditional statement to check for browser support of the HTML5 placeholder feature, and execute code to replicate this feature if the condition returns a flasy value.

  1. In your text editor, open index.htm from the HandsOnProject3-2 folder in the Chapter03 folder. Update the comment section
  2. Open index.htm in a modern browser.

At the bottom of the document, before the closing tag enter to create a new script section.

  1. Within the script section you created in the previous step, enter the following function:

function insertPlaceholders() {

if (!Modernizr.input.placeholder) {

document.getElementById(nameinput).value =

first and last name;

document.getElementById(emailinput).value =

address@example.com;

document.getElementById(phoneinput).value =

###-###-####;

}

}

This code references the placeholder property of the input property of the Modernizr object. The Modernizr library, which is linked to this document, is commonly used on the web to enable developers to create the same or similar experiences on both modern and older browsers. When a web page that uses Modernizr is opened in a browser, the library queries the browser to determine if it supports specific features used by the site.

  1. Below the code for the function, add the following backward-compatible event listener to call the function when the window finishes loading:

if (window.addEventListener) {

window.addEventListener(load, insertPlaceholders, false);

} else if (window.attachEvent) {

window.attachEvent(onload, insertPlaceholders);

}

  1. Save your file, zip your file(s) and upload to Javascript Inclass Exercise 3 folder on

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!