Get started with better-dateinput-polyfill CDN

MIT licensed

The better-dateinput-polyfill adds functionality, enhancing cross-browser date input usage.

Tags:
  • ecosystem:better-dom
  • web-components

Stable version

Copied!

How to start using better-dateinput-polyfill CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with better-dateinput-polyfill CDN - cdnhub.io</title>
  <link rel="stylesheet" href="styles.css">
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/polyfill.min.js"></script>
  <script src="https://cdn.cdnhub.io/better-dateinput-polyfill/3.3.1/better-dateinput-polyfill.min.js"></script>
</head>
<body>
  <label for="date">Select a date:</label>
  <input type="date" id="date" min="2022-01-01" max="2022-12-31">

  <script>
    document.addEventListener('DOMContentLoaded', () => {
      const dateInput = document.getElementById('date');
      if (!('valueAsNumber' in dateInput)) {
        window.Polyfill.load(() => {
          window.Intl.DateTimeFormat.prototype.format = (date, format) => {
            return new Intl.DateTimeFormat('en-US', format).format(date);
          };
          betterDateInput.polyfill();
          dateInput.type = 'better-date';
        });
      }
    });
  </script>
</body>
</html>
Copied!
Copied!

All versions