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

Fixes the card expiration date validations #145

Open benjisg opened 10 years ago

benjisg commented 10 years ago

This patch fixes two issues with the ExpirationInputView keydown bind function:

  1. Entering a month or year of 0 will cause the card to stick on the front face with no indication that the expiration is invalid. This happens because the internal date property as set to null
  2. If a month greater than 12 is entered, the original code would pass this to the javascript Date constructor, which would automatically increment the current date by (month value / 12) years. This would never cause a validation error because there is no bounds on the year check

This patch sets the date to January 1st, 1900 in order to trigger the expired date validation and display a problem on the card display.

Previous result with 0 as month screen shot 2014-06-26 at 2 44 25 pm

Previous result with 99 as month screen shot 2014-06-26 at 2 44 36 pm

New result with 99 as month screen shot 2014-06-26 at 2 56 20 pm