Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This validation doesn't ensure pincode is required, it should be ensured by field settings.
This validates only to ensure pincode is 00000 or 000000.
$pincode = $form_values['submitted_tree']['post_code'];
if (strlen(trim($pincode)) > 0){
if (!ereg('^[0-9]{5,6}$', $pincode)) {
form_set_error('submitted][post_code', t('Postal Code must be numeric and format nnnnn or xxxxxx.'));
}
}
Comments
Adding in the nnnnn-nnnn
Nothing unreal exists.