Problem with frm_validate_entry validation timing

By: Josen Ruiseco | Asked: 08/04/2024
ForumsCategory: Code HelpProblem with frm_validate_entry validation timing
Josen Ruiseco asked 5 months ago
See my form here: https://www.onlineprayerguy.com/
  1. Answer the first question with any answer and CONTINUE TO NEXT STEP.
  2. The form moves to the next page with a custom validation check and error. 
  3. PROBLEM: the validation is checking at the loading of the next page instead of waiting for the submit to the next step.
  4. CUSTOM FILTER: Require one of the two fields to have input before continuing.
add_filter('frm_validate_entry', 'check_category_fields', 10, 2);
function check_category_fields( $errors, $values ) {
if ( $values['form_id'] == 2 ) { // change to your form id
$group_fields = array(35, 36); // change to the ids of your fields
foreach ( $group_fields as $field_id ) {
if ( $_POST['item_meta'][$field_id] != '' ) {
return $errors; // do not continue checking if any of these fields have a value
}
}
foreach ( $group_fields as $field_id ) {
$errors['field'. $field_id] = 'Please fill in one of the category fields.';
}
}
return $errors;
}     5. What can I do to cause the filter to run the validation when the user selects the next submit button instead of firing when the step loads? 
2 Answers
Victor Font answered 5 months ago
Next is still a submit button. Form validations run on every submit.
Josen Ruiseco answered 5 months ago
What is the best way to delay the custom filter validation until the final form submit?

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right