function _postal_code_validation_validate_JP in Postal Code Validation 7
Implements _postal_code_validation_validate_COUNTRYCODE().
File
- countries/
jp.inc, line 11 - Postal code validation functions for Japan.
Code
function _postal_code_validation_validate_JP($postal_code) {
$return = array(
'country' => 'JP',
);
if (preg_match('/^([0-9]{3})-?([0-9]{4})$/', $postal_code, $matches)) {
$return['postal_code'] = $matches[1] . '-' . $matches[2];
}
else {
$return['error'] = t('Invalid postal code. Postal codes in Japan are like "999-9999".');
}
return $return;
}