Custom validation features are used to define validation rules using Regular Expressions. All these custom validators will be available in the Validations drop-down to set validations when creating or editing product fields.
To create new custom validators:
-
Navigate to the Advanced Settings tab (WooCommerce → Extra Product Option → Advanced Settings)
-
From the sections Custom validators, create new validators by providing all the required values.
- Validator Label
The display name for the validation rule - Validator Pattern
A regular expression, which is used to match a valid input. The regular expression must be prefixed with /^ and suffixed with $/. Eg: /^[0-9]{5}$/
- Validator Message
The message to be displayed when the validation fails. Use %s to include the field name in the validation messages.
- Validator Label
-
- Once added required validators, click on the Save changes button.
- The newly created validators will be available to choose from the Validations drop-down.
Comments
0 comments
Please sign in to leave a comment.