3

There's a class called "validate-zip" and "validate-zip-international". How does that function know how many digits to validate against? Where do you adjust the settings that affect how many digits to validate against?

This is for Magento 1

3
  • You can see magento 2 validations at /lib/web/mage/validation.js from your magento root Commented Apr 6, 2018 at 9:14
  • 1
    Forgot to mention that this is for Magento 1 Commented Apr 6, 2018 at 9:22
  • 1
    @angelo12 did my answer not answer your question? Commented Apr 13, 2018 at 8:19

1 Answer 1

5

You can see all of the validation rules in js/prototype/validation.js

['validate-zip', 'Please enter a valid zip code. For example 90602 or 90602-1234.', function(v) { return Validation.get('IsEmpty').test(v) || /(^\d{5}$)|(^\d{5}-\d{4}$)/.test(v); }], 

If we inspect the regex code: /(^\d{5}$)|(^\d{5}-\d{4}$)/
It validates for these formats: 12345 or 12345-1234

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.