Changeset - 2d96daee903c
[Not reviewed]
0 1 0
Bradley Kuhn (bkuhn) - 7 years ago 2014-12-04 01:44:15
bkuhn@ebb.org
Rework Javascript final form validation.

The problem before was that an error in the annual form would prevent
submission of the monthly form and vice-versa. That is herein corrected
with this change, which assures that the input with id of "amount" if
the specific form (id'd with "annual" or "monthly") is the only one
checked.
1 file changed with 14 insertions and 8 deletions:
0 comments (0 inline, 0 general)
www/conservancy/static/supporter-page.js
Show inline comments
...
 
@@ -64,15 +64,21 @@ $(document).ready(function() {
 
            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")
 
    var validateFormAtSubmission = function(element, event) {
 
            var valid = element.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");
 
        }
 
	        event.preventDefault();
 
            } else {
 
                $("#form-correction-needed").removeClass("form-error-show").addClass("form-error");
 
            }
 
    };
 
    $(".supporter-form-submit#monthly").click(function (event) {
 
        validateFormAtSubmission($(".supporter-form#monthly input#amount"), event);
 
    });
 
    $(".supporter-form-submit#annual").click(function (event) {
 
        validateFormAtSubmission($(".supporter-form#annual input#amount"), event);
 
    });
 
    /* Handle toggling of annual/monthly form selections */
 
    $('.supporter-type-selection#monthly').hide();
0 comments (0 inline, 0 general)