Skip to content
This repository has been archived by the owner on Jan 10, 2018. It is now read-only.

Month validation #76

Closed
ambasador opened this issue Feb 21, 2014 · 1 comment
Closed

Month validation #76

ambasador opened this issue Feb 21, 2014 · 1 comment

Comments

@ambasador
Copy link

Can anyone help me with this why is always giving me false

   $.payment.validateCardMonthExpiry = function(month) {
   var currentTime, expiry, _ref;

    if (typeof month === 'object' && 'month' in month) {
        _ref = month, month = _ref.month;
    }
    if (!month) {
        return false;
    }
    month = $.trim(month);

    if (!/^\d+$/.test(month)) {
        return false;
    }
    if (!(parseInt(month, 10) <= 12)) {
        return false;
    }
   expiry = new Date(month);
   currentTime = new Date;
   expiry.setMonth(expiry.getMonth() - 1);
   expiry.setMonth(expiry.getMonth() + 1, 1);
   return expiry > currentTime;

};

and when i validate this like that

if (!$.payment.validateCardMonthExpiry($('#month-holder').val())) {
        $('#month-error').fadeIn('slow');

    } else {
        $('#month-error').fadeOut('slow');
    }
@jamesreggio
Copy link
Contributor

Sorry, $.payment.validateCardMonthExpiry is not a feature of jquery.payment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants