Conditionally require a field using checkbox not working

By: Jody Slabaugh | Asked: 12/02/2023
ForumsCategory: Code HelpConditionally require a field using checkbox not working
Jody SlabaughJody Slabaugh asked 5 months ago

I successfully did this using radio box field following this code

https://formidableforms.com/knowledgebase/frm_validate_field_entry/#kb-conditionally-require-a-field

I changed my mind about using a radio box because my field was "How would you like notifications" with 3 radio choices, email, text, both (email and text).  My form is getting too messy so I thought I would just change that field to checkbox with two choices, email and text  The end user could also choose one or both.  

The issue I'm having is I wanted form validation so if the user chooses email notification, he must enter an email address in the email field.  If he chooses text notification, the user must enter a phone number, and of course, if the user checks both, he must enter an email and phone.  

The code from that KB document doesn't work for the checkbox field for some reason, and I can't figure it out.  Does anyone have a suggestion?    

Attachments
1 Answers
Rob LeVineRob LeVine answered 5 months ago
I suggest not using the frm_validate_field_entry hook at all and simply using the Conditional Logic with the fields themselves. Make both the email and phone number fields required and set their conditional logic to show when the checkbox is checked.

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