Closed Scrum closed 5 years ago
This is expected, as the pattern it toggles to has 15 characters instead of 16 characters. When the input starts at 16 characters and then is restricted to 15 characters, it makes sense that the final character would be cut off when toggled back.
This particular example is emulating a toggle between a non-American Express card (which usually has 16 digits) and an American Express card (which only has 15 digits).
Your truth, but I noticed another mistake while trying to understand the reasons for this behavior. This can be seen on my demo page There you may notice that I obviously change the value of the element
function setUnionpay() {
element.value = data.unionpay.value;
formattedCreditCardInput.setPattern(creditCardGapsPattern(data.unionpay.gaps, data.unionpay.lengths));
}
function setAmex() {
element.value = data.amex.value;
formattedCreditCardInput.setPattern(creditCardGapsPattern(data.amex.gaps, data.amex.lengths));
}
then the unformat method does not take into account the characters used in the pattern.
I created a PR where there is a playback test
@crookedneighbor tagging you just in case you don’t see this, otherwise.
General information
Issue description
Bug can look at https://braintree.github.io/restricted-input/
Steps
Card Number (toggle-able)
toggle
twice4111 1111 1111 111