Skip to content

Instantly share code, notes, and snippets.

@garystorey
Created July 21, 2017 16:43
Show Gist options
  • Select an option

  • Save garystorey/7bf9f6410ad547a4370a3d877628173e to your computer and use it in GitHub Desktop.

Select an option

Save garystorey/7bf9f6410ad547a4370a3d877628173e to your computer and use it in GitHub Desktop.
var testInputType = (function(GOOD, BAD) {
'button checkbox color date datetime datetime-local email month number password radio range reset search submit tel text time url week'.replace(/\S+/g, function(typeName) {
var input = document.createElement('input');
input.setAttribute('type', typeName);
(input.type.toLowerCase() == typeName ? GOOD : BAD).push(typeName);
});
return function(value) {
return 'boolean' == typeof value ? (value ? GOOD : BAD).slice() : GOOD.includes(value.toLowerCase());
};
})([], []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment