Form fields placeholder fallback for IE using jQuery
placeholderfallback
is a small jQuery plugin providing support for browsers that do not support the placeholder
attribute for form fields, in particular for Internet Explorer 9 and lower, and Opera Mini 8. This plugin makes use of give placeholder
attribute to set and display the values accordingly.
Bower
$ bower install placeholder-fallback
<script src="path/to/jquery.placeholderfallback.js" type="text/javascript"></script>
<!doctype HTML>
<html>
<head>
<title>Example</title>
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="bower_components/placeholder-fallback/dist/jquery.placeholderfallback.js"></script>
</head>
<body>
<form>
<input type="text" id="firstNameField" placeholder="First Name">
<input type="text" id="lastNameField" placeholder="Last Name">
<input type="email" id="emailField" placeholder="Email address">
</form>
<!--[if lt IE 10]>
<script>
$('#firstNameField, #lastNameField, #emailField').placeholderfallback();
</script>
<![endif]-->
</body>
</html>
Requires jQuery 1.8 +
MIT License - © Jabran Rafique