Required Fields defined by another field

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
longbo43
Forum Newbie
Posts: 10
Joined: Tue Apr 20, 2010 2:33 am

Required Fields defined by another field

Post by longbo43 »

I have a form that has a huge number of fields on it. Well I think it is a huge number of fields.
I have been able to set certain fields as required.

But the client has now come back and asked that if a certain option is selected from particular dropdowns on the form other boxes will become required.

For example:

I have three fields a, b and c
a and b are drop down boxes.
a contains the options 1, 2, 3 - Is Required
b contains options 4, 5, 6 - Is Required
c is a text entry box - Is Not Required

At the moment c is not required but what the client wants is if a user selects option 1 from dropdown a then c becomes required but if option 2 or option 3 are selected c remains not required.

The client requirements could be that not just c but d, e and f become required.

Hopefully this explains what I am looking to do and hopfully someone can Help.

I'll also give you some info about me. I do not know or understand PHP. I used PHPRunner 5.2 to create the PHP for and any associated code.
I don't even know what to post here to help out but please request and I will make available anything that can help.

Cheers
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Required Fields defined by another field

Post by Jonah Bron »

I think the best way to approach variable requirements is with a multi-page form. If a input element may or may not be required, depending on the value of another input field, put it on the next page.
longbo43
Forum Newbie
Posts: 10
Joined: Tue Apr 20, 2010 2:33 am

Re: Required Fields defined by another field

Post by longbo43 »

Hi an thanks for your response.

How would I be able to do this as I am using PHP Runner to create my form. Also how would I call the subform (is that what it is??) and how would I set the variables to call it?

Cheers
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Required Fields defined by another field

Post by Jonah Bron »

I don't know anything about PHP Runner. Here's how it will work.

Code: Select all

Page 1
    display form
Page 2
    accept data from page 1, and store in session
    display form
Page 3
    accept data from session and page 2, and do something.
    display complete message
Post Reply