cancel
Showing results for 
Search instead for 
Did you mean: 

Limit amount of digits being input into postal code?

Limit amount of digits being input into postal code?

Our site handles orders from both Canada and the USA.  Postal codes in Canada are 6 digital alphanumeric while the US has 5 numeric digits.  For some reason one of your customers from the USA placed an order this moring with a postal code like this 95864-8976.  The system allowed him to use it and when he placed his order the postal code wasn't recognized by my tax rules and his order when through without having the proper state taxes applied to the price.  Is there a way to limit it to 6 digits?

 

Thanks

2 REPLIES 2

Re: Limit amount of digits being input into postal code?

You can add in phtml file for billing & shipping address fields class

validate-length maximum-length-6

Files are app/design/frontend/{theme}/{package}/template/checkout/onepage/billing.phtml

and app/design/frontend/{theme}/{package}/template/checkout/onepage/shipping.phtml

 

It will look like: 

 

<input type="text" class="form-control validate-length maximum-length-6 validate-zip-international  required-entry validation-failed" value="" id="billing:postcode" name="billing[postcode]" title="Zip/Postal Code">

Re: Limit amount of digits being input into postal code?

What about the documentation page about "Add custom input mask for ZIP code"  http://devdocs.magento.com/guides/v2.1/howdoi/checkout/checkout_zip.html ?