I wanted to make a function for the validation of postal code to customize an error message if possible. I wonder if you have an idea.
Here's an idea of my function:
// checks postal code format L4X-1S9
$regex = '/[a-z][0-9][a-z][- ]?[0-9][a-z][0-9]$/i';
if( preg_match($regex, $zip) )
echo "Valid postal code";