Validating Pincode / Post Code
Last updated on
30 April 2025
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.'));
}
}
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion