Changeset - b2c18cc59e52
[Not reviewed]
0 1 0
Bradley Kuhn (bkuhn) - 9 years ago 2014-12-02 22:04:05
bkuhn@ebb.org
Correct regular expression and comma thing fully.

parseInt() likely wants no commas, so we use a value without it, and the
regular expression now seems to properly match was PayPal will take as
valid.
1 file changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
www/conservancy/static/supporter-page.js
Show inline comments
...
 
@@ -36,9 +36,10 @@ $(document).ready(function() {
 
        var input=$(this);
 
        var value = input.val();
 
        var errorElement=$("span", input.parent());
 

	
 
        var re = /^[0-9,\.]+$/;
 
        var isValid = (re.test(value) && parseInt(value) >= 120);
 
        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");
0 comments (0 inline, 0 general)