kenkeiter / skeuocard

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

card validate #130

Open yingjun opened 10 years ago

yingjun commented 10 years ago

I filled all info, and expire date with 33/12. card.isValid() return true. it should return false.

ssimmons42 commented 9 years ago

The function starting on line 1201 of skeuocard.js (ExpirationInputView.prototype._onKeyUp) takes the number you input and returns a date object. For some reason, if you use a month > 12 it will return a valid but incorrect date object. I made a workaround for this.

It was returning the date as long as month and year are not equal to zero. It was doing this by these lines: dateObj = new Date(year, month - 1, day); this.date = dateObj;

I changed it to return a date in the past if the month is > 12 like this: if (month <=12) { dateObj = new Date(year, month - 1, day); } else { dateObj = new Date(1900,1,1); } this.date = dateObj;

Since 1900 is in the past, Skeuocard recognized it as an invalid date.