UNPKG

date-input-polyfill

Version:

Automatically adds datepickers to input[type=date] on IE, Firefox, and OS X Safari.

58 lines (48 loc) 1.52 kB
<!DOCTYPE html> <html style="height: 100%;"> <head> <meta charset="UTF-8"> <title>Polyfill Test</title> <meta name="description" content="Polyfill Test"> <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> </head> <body style="width: 200%; height: 200%;"> <p> normal: <input type="date" /> <script> var theDate = document.querySelector('input[type="date"]'); theDate.addEventListener('change', function() { console.log('blank date input:', theDate.value); }); </script> </p> <p> with value: <input type="date" value="2015-03-28" lang="test" /> </p> <p> with format ("date-format"): <input type="date" lang="test" date-format="mm/dd/yyyy" /> </p> <p> with format ("data-date-format"): <input type="date" lang="test" data-date-format="mm/dd/yyyy" /> </p> <p> text class with format: <input class="date-polyfill" type="text" lang="test" date-format="mm/dd/yyyy" /> </p> <p id="dynamic" style="margin-top: 25%; margin-left: 25%;"> dynamically created: <script> setTimeout(function() { var input = document.createElement("input"); input.setAttribute("type", "date"); document.getElementById("dynamic").appendChild(input); }, 2000); </script> </p> <script src="date-input-polyfill.dist.js"></script> </body> </html>