From 090fb9f268a018ae2ddab5562203a20a4e55fcc9 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Tue, 2 Dec 2014 17:26:55 -0500 Subject: [PATCH] Larger error message when submitting bad amount. This addition to the Javascript and text ensures a clear message to the user of a Javascript-enabled browser that there is an issue with the amount. Also, it prevents submission of the form until the amount is correct. A user with Javascript disabled can circumvent these validation steps; however, the worst-case scenario is that they make a donation for less than $120 that is categorized in Conservancy's internal system as a Supporter donation, and we'll be adding internal checks to find that. --- www/conservancy/static/supporter-page.js | 11 +++++++++++ www/conservancy/static/supporter/index.html | 1 + 2 files changed, 12 insertions(+) diff --git a/www/conservancy/static/supporter-page.js b/www/conservancy/static/supporter-page.js index 2e76d12c..7593ad83 100644 --- a/www/conservancy/static/supporter-page.js +++ b/www/conservancy/static/supporter-page.js @@ -43,12 +43,23 @@ $(document).ready(function() { if (isValid) { input.removeClass("invalid").addClass("valid"); errorElement.removeClass("form-error-show").addClass("form-error"); + $("#form-correction-needed").removeClass("form-error-show").addClass("form-error"); } else { input.removeClass("valid").addClass("invalid"); errorElement.removeClass("form-error").addClass("form-error-show"); } }); + $("#supporter-form-submit").click(function(event){ + var valid = $('#amount').hasClass("valid"); + if (! valid) { + $("#form-correction-needed").removeClass("form-error").addClass("form-error-show") + .css("font-weight", "bold").css("font-size", "150%"); + event.preventDefault(); + } else { + $("#form-correction-needed").removeClass("form-error-show").addClass("form-error"); + } + }); /* Handle toggling of annual/monthly form selections */ $('.supporter-type-selection#monthly').hide(); $('#annualSelector').css("font-weight", "bold").css("font-size", "127%"); diff --git a/www/conservancy/static/supporter/index.html b/www/conservancy/static/supporter/index.html index e9016674..f62fd1ef 100644 --- a/www/conservancy/static/supporter/index.html +++ b/www/conservancy/static/supporter/index.html @@ -234,6 +234,7 @@ internal policies are published and available for scrutiny.

options to the right first. +Please ensure all form data above is correct. {% endblock %}