mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-10 15:37:30 +00:00

* Listen to "input" event only, don't need "keyup" * Add form double-submit protection * Rewrite in plain JS (the page no longer loads jQuery)
15 lines
557 B
JavaScript
15 lines
557 B
JavaScript
window.addEventListener("DOMContentLoaded", function(e) {
|
|
var validateAndSubmit = function() {
|
|
if (this.validity.valid && !this.dataset.submitted) {
|
|
// Make sure we only submit the form once
|
|
this.dataset.submitted = true;
|
|
this.form.submit();
|
|
}
|
|
}
|
|
|
|
// Hook up validateAndSubmit to all input elements with the
|
|
// "data-auto-submit" attribute
|
|
document.querySelectorAll("input[data-auto-submit]").forEach((input) => {
|
|
input.addEventListener("input", validateAndSubmit);
|
|
});
|
|
});
|