Validating individual fields
Advanced Forms uses ACF to render and validate fields. This means that any custom field validations will also work with your forms. ACF provides the
acf/validate_value to add extra validation logic for specific fields and it’s the recommended way to add validation logic for form fields as well. Refer to the ACF documentation for more info.
Sometimes it’s not sufficient to validate individual fields. From version 1.5 and onwards, Advanced Forms includes the ability to add custom validation logic for full forms. This is made possible with the
af/form/validate action combined with the
af/form/validate is invoked before submission and has access to the submitted data through
The following is an example of custom validation involving two separate fields. The
af_add_error functions takes a field name (or key) as its first parameter and an error message as its second.