kenkeiter / skeuocard

Skeuocard progressively enhances credit card inputs to provide a skeuomorphic interface.
http://kenkeiter.com/skeuocard/
MIT License
3.23k stars 231 forks source link

Single face card (front only) fails on isValid() #144

Open caruccio opened 10 years ago

TheRyanBurke commented 10 years ago

When can we expect a new release with this change?

estenp commented 9 years ago

Thank you for addressing this issue. I was struggling with validating AmEx. Needs to be merged

I did run into an issue, though, where if you were trying to validate before the card had began rendering, or before this.product exists, as I see it, the validation using card.isValid() would throw an error because this.product cannot be found. For example if you tried to submit before ever touching the "card". I altered your addition like so:

if (this.product) {
     if (this.product.faces === 'both') {
       return !this.el.front.hasClass('invalid') && !this.el.back.hasClass('invalid');
     } else if (this.product.faces === 'front') {
       return !this.el.front.hasClass('invalid');
     } else {
       return !this.el.back.hasClass('invalid');
     }
  } else {
    return false;
  }

This seems to be working for me, so far.