Skip to content

Instantly share code, notes, and snippets.

@skew202
Created November 2, 2016 15:03
Show Gist options
  • Save skew202/00bdab78878667300cedbcf04945ff59 to your computer and use it in GitHub Desktop.
Save skew202/00bdab78878667300cedbcf04945ff59 to your computer and use it in GitHub Desktop.
// plainforms.js
// https://github.com/bgrins/devtools-snippets
// Remove HTML5 form features (validations and special input types).
(function () {
['maxlength', 'required', 'min', 'max', 'pattern', 'step' ].forEach(function (attr) {
[].forEach.call(document.querySelectorAll("[" + attr + "]"), function (node) {
node.removeAttribute(attr);
});
});
['tel', 'url', 'email', 'datetime', 'date', 'month', 'week', 'time', 'datetime-local', 'number', 'range', 'color'].forEach(function (type) {
[].forEach.call(document.querySelectorAll("input[type=" + type + "]"), function (node) {
node.setAttribute('type', 'text');
});
});
console.info("All HTML5 form validations have been removed.");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment