View Full Version : Creating a form with some answers requiring different sub answers

11-01-2007, 12:43 AM
I'm not sure if this should be under this category or the javascript category. But I want to do a simple registration form, but certain fields are required based on their answers in the form.

For example, if they click the radio button member, then they only need to fill out 2 of the 5 fields. If they click non member the form needs to require them to fill out everything.

How would I go about doing this?

11-01-2007, 04:25 AM
The easy way to tell what the solution is would be to consider "is what I'm trying to do content, structure, presentation, or behavior?" Content is pretty much basic HTML, structure and presentation typically lies under CSS, and behavior is almost always Javascript.

But yes you would want a Javascript approach. The easy algorithm would be in your validation function (which would be fired from the onsubmit from the form) to check those radio buttons to see which one is selected, and require different forms depending on what's active.