jondavidjohn / payform

:credit_card: A library for building credit card forms, validating inputs, and formatting numbers.
https://jondavidjohn.github.io/payform/
Other
427 stars 81 forks source link

Feature/restrict expiry with maxlength #7

Closed ds0001 closed 9 years ago

ds0001 commented 9 years ago

update restrictExpiry method to accept an override value from an html element data attribute 'data-maxlength'. Nmp tests run green and I didn't see any specific tests on this method so I didn't bother with a new test.

Reason: I wanted to restrict it to 4 digits MMYY. The parseCardExpiry method allowed for 2 digits for year but the restrictExpiry method did not. I started with just using maxlength on the html input but felt it better to use a data attribute instead. Its possible the formatter could change from " / " to something else in which case the html input would have an incorrect maxlength attribute.

jondavidjohn commented 9 years ago

Appreciate the thought, but is there a specific reason you want to not allow for 4 digit years? You can easily prompt the user for this format (see the example page), in either case parsing the values turns out the same.

ds0001 commented 9 years ago

Sorry about the barrage of pull requests. The main reason to restrict to 2 digit years is for faster form input and feedback.

jondavidjohn commented 9 years ago

Right, I guess I'm saying that this is currently possible and you can indicate to the user this is possible (like on the example page), don't see the real value in the hard restriction.

ds0001 commented 9 years ago

Gotcha. Thanks for taking a look.

jondavidjohn commented 9 years ago

:+1: