Hello Shane,
As I told you in the first message, we used your solution posted here: https://toolset.com/forums/topic/required-cred-checkboxes/ on one form and it actually works. The problem is that it is not working with other forms. The other forms have the same type of checkboxes (those forms are used for posting premium posts, but all of them are created in the same way).
Out question wasn't if it works on our fields (because we saw it work). The question is: How can we make it work on other forms as well?
Thank you!
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Valentine,
Could you let me see that other form, the one that you said it worked on ?
Thanks,
Shane
Hello,
It is the form with the ID 25559 > Add New Opportunities Form User Paid Listing Basic (ID: 25559)
It creates posts in Business Opportunities CPT.
Thx!
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Valentin,
I'm not sure how this even worked in the first place since we are working taxonomies.
I know our documentation shows this implementation for custom fields. Even your code here
function my_validation($field_data, $form_data)
{
//field data are field values and errors
list($fields,$errors)=$field_data;
//uncomment this if you want to print the field values
//print_r($fields);
//validate if specific form
if ($form_data['id']==25559)
{
//check if field is selected
if (empty($fields['wpcf-type_of_proposal']['value']))
{
//set error message for featured image
$errors['wpcf-type_of_proposal'] = 'Please Specify if you are looking to Buy or Sell';
}
}
//return result
return array($fields,$errors);
}
Works only for custom field. If you check the form you won't find any fields with the name "wpcf-type_of_proposal".
Even as you say in your initial message that it works on the page here.
hidden link
When I performed my testing the validation doesn't work at all.
Maybe if you can send a screenshot of this working I will try to see why i'm not seeing it working but your initial code doesn't work. Also from my understanding the validation hook doesn't cover taxonomies.
Thanks,
Shane
Hello,
Can you please help us with the JS implementation to make one of those fields required?
Thx!
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Valentin,
Just add this to your form's JS editor.
jQuery("input[name='type-of-proposal[]']").attr("required", "true");
Thanks,
Shane
Hello,
This makes both of them required. We need a code to make only one of them required (the user must choose if he wants to sell or to buy, not both).
Thx.