Skip to content

Instantly share code, notes, and snippets.

@thet
Last active July 20, 2020 15:43
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 thet/4171d3f7f5b075d7360c0927c9ffb353 to your computer and use it in GitHub Desktop.
Save thet/4171d3f7f5b075d7360c0927c9ffb353 to your computer and use it in GitHub Desktop.
input type date validity test
let form = document.createElement('form');
let el = document.createElement('input');
el.setAttribute('type', 'date');
el.setAttribute('name', 'okay');
form.appendChild(el);
document.body.appendChild(form);
let input = document.querySelector('form input');
input.value = 'lsk';
console.log(input.validity.valid); // says ``true``, should be ``false``
console.log(input.validity.badInput); // says ``false``, should be ``true``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment