function commerce_payment_validate_credit_card_start_date in Commerce Core 7
Validates a credit card start date.
Parameters
int $month: The 1 or 2-digit numeric representation of the month, i.e. 1, 6, 12.
int $year: The 4-digit numeric representation of the year, i.e. 2010.
Return value
TRUE for cards whose start date is blank (both month and year) or in the past, 'year' or 'month' for expired cards indicating which value should receive the error.
1 call to commerce_payment_validate_credit_card_start_date()
- commerce_payment_credit_card_validate in modules/
payment/ includes/ commerce_payment.credit_card.inc - Validates a set of credit card details entered via the credit card form.
File
- modules/
payment/ includes/ commerce_payment.credit_card.inc, line 324 - Credit-card helper functions for Drupal commerce.
Code
function commerce_payment_validate_credit_card_start_date($month, $year) {
if (empty($month) && empty($year)) {
return TRUE;
}
if (empty($month) || empty($year)) {
return empty($month) ? 'month' : 'year';
}
if ($month < 1 || $month > 12) {
return 'month';
}
if ($year > date('Y')) {
return 'year';
}
elseif ($year == date('Y')) {
if ($month > date('n')) {
return 'month';
}
}
return TRUE;
}