Question: In this project, youll use a conditional statement to check forbrowser support of the HTML5 placeholder feature, and execute codeto replicate this feature if the

In this project, you’ll use a conditional statement to check forbrowser support of the HTML5 placeholder feature, and execute codeto replicate this feature if the condition returns a flasyvalue.

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 lastname”;

document.getElementById(“emailinput”).value =

“address@example.com”;

document.getElementById(“phoneinput”).value =

“###-###-####”;

}

}

This code references the placeholderproperty of the input property of the Modernizr object. TheModernizr library, which is linked to this document, is commonlyused on the web to enable developers to create the same or similarexperiences on both modern and older browsers. When a webpage that uses Modernizr is opened in a browser, the libraryqueries the browser to determine if it supports specific featuresused by the site.

Below the code for the function, add the followingbackward-compatible event listener to call the function when thewindow finishes loading:

if (window.addEventListener) {

window.addEventListener(“load”, insertPlaceholders, false);

} else if (window.attachEvent) {

window.attachEvent(“onload”, insertPlaceholders);

}

The text:


Hands-on Project 3-2

<(script)src="modernizr.custom.58072.js"><(/script)>







Hands-on Project 3-2


ContactInformation

Name



Email

Phone


<(script)>


<(/script)>


Step by Step Solution

3.29 Rating (146 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

It looks like youre working on a project to check for browser support of the HTML5 placeholder featu... View full answer

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 Programming Questions!