Validating credit card expiration date

The following form requires to provide a valid expiration month and year of credit card. Because the date validator asks for all the year, month and day, it isn't helpful in that case.

Instead, we will use the callback validator to check the validity of month and year fields. Because these fields depend on each other, the updateFieldStatus() method is used to set month/year field as valid one.

Note

For demonstrating purpose, the expiration date is treated as valid if it is in the range of current month and next 10 year

More examples

Related validators

The following validators might be useful to you.