Second question in one day!!
I want a field mandatory if the user has answered yes to a prior field. but is not mandatory if they answered no.
For example:
Yes- I have kids
How many? mandatory if they answer yes to above question.
Relating fields to eachother.
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Relating fields to eachother.
You can do this with Javascript for a single page solution, or use PHP to check submitted values and either add the field or ask for it on an additional page.
(#10850)
Re: Relating fields to eachother.
This can be dealt with many ways. One approach would be to generate an array of which fields are required.
Then later when checking required fields, you can easily loop through the array.
Code: Select all
if($has_kids) $required_fields[] = 'kid_count';