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.
This commit is contained in:
parent
9c40bf2e60
commit
2d96daee90
1 changed files with 14 additions and 8 deletions
|
@ -64,8 +64,8 @@ $(document).ready(function() {
|
|||
errorElement.removeClass("form-error").addClass("form-error-show");
|
||||
}
|
||||
});
|
||||
$("#supporter-form-submit").click(function(event){
|
||||
var valid = $('.amount').hasClass("valid");
|
||||
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%");
|
||||
|
@ -73,6 +73,12 @@ $(document).ready(function() {
|
|||
} 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();
|
||||
|
|
Loading…
Reference in a new issue