How to add Custom Validation Rules in WooCommerce Checkout Field Editor

Themehigh
1 min readOct 12, 2018

--

Custom validator feature can be used to define custom validation rules using RegEx which can be selected from ‘Validations’ drop-down when creating or editing checkout fields.

To create new custom validators,

  1. Go to Checkout Form > Advanced Settings page.
  2. Click on Add New Validator button to get new validator settings row.
  3. Enter the validator settings.
  • Validator Name: A unique name for the validation rule, which will be used internally to identify the validator.
  • Validator Label: The display name for the validation rule.
  • Validator Pattern: A regular expression which is used to match a valid input.
  • Error Message: The message to be displayed when the validation fails. Use %s to include field name in validation messages.
  1. Save settings.
  2. Newly created validators will be available to choose in Validations drop-down.
  1. Done.

--

--

Themehigh
Themehigh

Written by Themehigh

Themehigh develops WordPress and WooCommerce plugins that are being used by 2 million users around the globe.

No responses yet