Skip to content

Commit

Permalink
Automatically add leading 0 to expiry date. (#72)
Browse files Browse the repository at this point in the history
if it starts iwth a digit bigger that 1
  • Loading branch information
ElforL committed Sep 6, 2022
1 parent 7d1b4fe commit cbee456
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/credit_card_form.dart
Expand Up @@ -132,6 +132,9 @@ class _CreditCardFormState extends State<CreditCardForm> {
});

_expiryDateController.addListener(() {
if (_expiryDateController.text.startsWith(RegExp('[2-9]'))) {
_expiryDateController.text = '0' + _expiryDateController.text;
}
setState(() {
expiryDate = _expiryDateController.text;
creditCardModel.expiryDate = expiryDate;
Expand Down

0 comments on commit cbee456

Please sign in to comment.