Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2007
    Thanked 0 Times in 0 Posts

    Creating a form with some answers requiring different sub answers

    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?

  2. #2
    Regular Coder
    Join Date
    Sep 2007
    Raleigh, NC
    Thanked 59 Times in 52 Posts
    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts