sutty/app/javascript/etc/input-date.js

12 lines
394 B
JavaScript
Raw Permalink Normal View History

2021-04-07 20:45:27 +00:00
// Validar fechas en navegadores que no soportan date, como
// Webkit/Safari
document.addEventListener('turbolinks:load', () => {
document.querySelectorAll('input[type="date"]').forEach(date => {
if (date.type === 'date') return
date.addEventListener('change', event => {
date.setCustomValidity(date.validity.patternMismatch ? date.dataset.patternMismatch : '')
})
})
})