
MAGENTO 1.X – NO PO BOX IN SHIPPING AND/OR BILLING ADDRESS
In some cases, people adds his PO Box number to the shipping or billing address. To Make a restriction on that, you need to add the following Magento Validation script on the corresponding phtml, as follows:
1 2 3 4 5 |
<script> Validation.add('no-po-box', 'The shipping address must be a physical address. PO Boxes are allowed for billing only.', function(v) { return /^box.*|^po.*box.*|^p\.o\..*box.*/i.test(v) === false; }); </script> |
Also, you need to add on the corresponding <input> the class no-po-box to let the script recognize the regular expression.
If you want to make this validation on the checkout shipping / billing input fields, you need to change the following files:
1 2 |
app/design/frontend/<your-theme>/default/template/checkout/onepage/shipping.phtml app/design/frontend/<your-theme>/default/template/persistent/checkout/onepage/billing.phtml |
Then you can make a try and you should see the validation in there.
Note: This kind of validations are useful for any input text. You can change the regular expression whenever you want, and assign the Validation to the input class in the corresponding phtml.