Skip to content

Instantly share code, notes, and snippets.

@zooks
Created August 29, 2022 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zooks/037da7ebf61a35448de8c539e7dcb6c9 to your computer and use it in GitHub Desktop.
Save zooks/037da7ebf61a35448de8c539e7dcb6c9 to your computer and use it in GitHub Desktop.
Cleave.js apply to all elements with specific classname
window.onload = function () {
var datesCollection = document.getElementsByClassName("input-date");
var dates = Array.from(datesCollection);
dates.forEach(function (date) {
new Cleave(date, {
date: true,
delimiter: '-',
datePattern: ['Y', 'm', 'd']
})
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment