How to add Custom Validation Rules in WooCommerce Checkout Field Editor
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,
- Go to Checkout Form > Advanced Settings page.
- Click on Add New Validator button to get new validator settings row.
- 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.
- Save settings.
- Newly created validators will be available to choose in Validations drop-down.
- Done.