Changeset - c54683398484
[Not reviewed]
0 1 0
Bradley Kuhn (bkuhn) - 9 years ago 2014-12-02 22:58:39
bkuhn@ebb.org
Amount starts class "valid", when default accepted

The default amount of $120 appears in the amount field, but the class
"valid" was usually only added when the user changes the amount.

The valid class must be added at the start to ensure someone simply
clicking with the default still can donate.
1 file changed with 1 insertions and 0 deletions:
0 comments (0 inline, 0 general)
www/conservancy/static/supporter-page.js
Show inline comments
...
 
@@ -23,24 +23,25 @@ $(document).ready(function() {
 
            $control.html($control.attr('data-text'));
 
        }
 
    });
 
    $('a.donate-now')
 
      .addClass('clickable')
 
      .bind('click', function() {
 
        var $control = $('#donate-box');
 

	
 
        $control.toggleClass('expanded');
 
        $control.find('.toggle-content').slideUp("slow");
 
        $control.find('.toggle-content').slideDown("slow");
 
    });
 
    $('#amount').addClass("valid");
 
    $('#amount').on('input', function() {
 
        var input=$(this);
 
        var value = input.val();
 
        var errorElement=$("span", input.parent());
 
        var noCommaValue = value;
 
        noCommaValue = value.replace(/,/g, "");
 
        var re = /^((\d{1,3}(,?\d{3})*?(\.\d{0,2})?)|\d+(\.\d{0,2})?)$/;
 
        var isValid = ( re.test(value) && parseInt(noCommaValue) >= 120);
 
        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");
0 comments (0 inline, 0 general)