-
-
Save mcshaz/c65040c11e6daffe356cbedb7ec84ce4 to your computer and use it in GitHub Desktop.
Revisions
-
mcshaz revised this gist
Apr 17, 2020 . 1 changed file with 23 additions and 20 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,23 +1,26 @@ if (!HTMLFormElement.prototype.requestSubmit) { HTMLFormElement.prototype.requestSubmit = function() { const submitBtn = document.createElement('input'); submitBtn.type = 'submit'; submitBtn.hidden = true; this.appendChild(submitBtn); submitBtn.click(); this.removeChild(submitBtn); }; } if (!HTMLFormElement.prototype.reportValidity) { HTMLFormElement.prototype.reportValidity = function() { if (this.checkValidity()){ return true; } if (this.noValidate){ this.noValidate = false; this.requestSubmit(); this.noValidate = true; } else { this.requestSubmit(); } return false; }; } -
newhope created this gist
Nov 21, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ /** Only work if your form has a submit button */ if ( ! HTMLFormElement.prototype.reportValidity) { HTMLFormElement.prototype.reportValidity = function () { var validity = this.checkValidity(); if ( ! validity) { var submitButtons = this.querySelectorAll("button, input[type=submit]"); for (var i = 0; i < submitButtons.length; i++) { if (submitButtons[i].type === "submit") { submitButtons[i].click(); return validity; } } } return validity; } }