HTML5 Form Validator Support Product Page

Answered

How can I make a field conditionally required based on a tick Box?

Asked 09 Nov 2016 03:18:14
1
has this question
09 Nov 2016 03:18:14 Colin Slater posted:
I have a text area in my form, that I want to be required if a checkbox in the form is ticked. How can I achieve this?
I've got the HTML5 Data Bindings also installed if that helps as I've seen similar articles about hiding and showing form fields using this.

Thanks

Colin

Replies

Replied 09 Nov 2016 12:18:35
09 Nov 2016 12:18:35 Teodor Kuduschiev replied:
Hello Colin,
Do you need to check a specific value from a checkbox?
Replied 09 Nov 2016 13:16:42
09 Nov 2016 13:16:42 Colin Slater replied:
No... it's not the checkbox that needs validating... it's the text area.

The website is a booking system for our activities on the scout camp site. The checkbox is for the person making the booking to indicate if there are any participants with additional needs in the group.
If this is checked, I want the 'Booking Notes' field (a textarea) to be made a required field so that we get some details about the additional requirements of the group and can plan accordingly.
Replied 09 Nov 2016 14:00:09
09 Nov 2016 14:00:09 Teodor Kuduschiev replied:
My question was actually if you check a specific value from the checkbox to make the text area required ...

On your page select the textarea (to be sure you selected it properly click on its tag in the properties inspector).
Then in the HTML5 Data Bindings Panel under $FORM click your checkbox.
Then, in the dropdown at the bottom of Data Bindings panel select textarea.data.required and click the bind button.
The required parameter will be added to the textarea when the checkbox has a value (when it is checked).
Replied 09 Nov 2016 15:21:06
09 Nov 2016 15:21:06 Colin Slater replied:
Perfect - working exactly as I want it to.
Thanks very much for your help.

Reply to this topic