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

update restrictExpiry to accept a restrict value override #5

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.

jondavidjohn commented 9 years ago

Interesting, thanks!

What specifically was the problem you were having with the static length restriction?

ds0001 commented 9 years ago

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.