Home › Forums › Front-end Issues › acf_form with custom validation message › Reply To: acf_form with custom validation message
It should work on the front end as well as the back end.
Check you acf_form setup. Are you calling acf_form_head();
before get_header();
and make sure that your theme is also calling wp_footer();
If something here is wrong it could be causing the JS to error.
Another thing is that if you have the field marked as required then if it’s left blank you’ll get the standard ACF error message. If you want to completely override that remove the check at the top of the function that returns if the field is already not valid
add_filter('acf/validate_value/name=password2', 'my_validated_password_filter', 10, 4);
function my_validated_password_filter($valid, $value, $field, $input) {
// field key of the field you want to validate against
$password_field = 'field_0123456789abc';
if ($value != $_POST['acf'][$password_field]) {
$valid = 'Does Not Match Password';
}
return $valid;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.