From 989f9ffb854efcd7cf651e49b87c9dc348616dbe Mon Sep 17 00:00:00 2001 From: Drew Larson Date: Mon, 1 May 2017 19:35:03 -0600 Subject: [PATCH] Disable form until valid. (#42) --- .../registration/templates/edit_member_form.html | 15 +++++++++++++-- .../registration/templates/member_form.html | 9 +++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/bikeshop_project/registration/templates/edit_member_form.html b/bikeshop_project/registration/templates/edit_member_form.html index 61064b1..50d2bc1 100644 --- a/bikeshop_project/registration/templates/edit_member_form.html +++ b/bikeshop_project/registration/templates/edit_member_form.html @@ -4,7 +4,8 @@ {% block scripts %} {% endblock %} @@ -220,7 +231,7 @@
-
diff --git a/bikeshop_project/registration/templates/member_form.html b/bikeshop_project/registration/templates/member_form.html index ffa6436..f04f595 100644 --- a/bikeshop_project/registration/templates/member_form.html +++ b/bikeshop_project/registration/templates/member_form.html @@ -25,6 +25,15 @@ var waiverCheckBox = document.getElementById('{{ form.waiver_substitute.id_for_label }}'); var submitButton = document.getElementById('submit'); + var form = document.getElementsByTagName('form')[0]; + var inputs = Array.prototype.slice.call(document.getElementsByTagName('input')); + + for (var anInput of inputs) { + anInput.addEventListener('change', function() { + submitButton.disabled = !form.checkValidity() + }) + } + var requiredCheckboxes = function() { return waiverCheckBox.checked; };