From 4c8b60b0eaecb4b303cf8bfec54d281ccaf3f10d Mon Sep 17 00:00:00 2001 From: Drew Larson Date: Wed, 25 May 2016 18:21:17 -0600 Subject: [PATCH] Enable submit button once everything is agreed to. --- .../core/templates/membership_form.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bikeshop_project/core/templates/membership_form.html b/bikeshop_project/core/templates/membership_form.html index 91f7165..530119b 100644 --- a/bikeshop_project/core/templates/membership_form.html +++ b/bikeshop_project/core/templates/membership_form.html @@ -154,5 +154,22 @@ this.parentNode.classList.add('is-dirty'); this.value = renewedAt.time.format('YYYY-MM-DD'); }) + + var responsibilities = [ + document.getElementById('{{ form.safe_space.id_for_label }}'), + document.getElementById('{{ form.respect_community.id_for_label }}'), + document.getElementById('{{ form.give_back.id_for_label }}'), + document.getElementById('{{ form.respect_shop.id_for_label }}') + ]; + var checkResponsiblities = function () { + allAgreed = responsibilities.every(function (checkbox) { + return checkbox.checked + }); + var submitButton = document.getElementById('submit'); + submitButton.disabled = !allAgreed; + }; + responsibilities.forEach(function (checkbox) { + checkbox.addEventListener('click', checkResponsiblities) + }) {% endblock %} \ No newline at end of file