PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Required field with condition

  1. Lea Cohen
    Member

    In the form I'm creating, I want the user to either upload a file from their computer, or insert a url from the web. So I created 2 fields, but really only one of the is required. How can I do this in a user friendly way?

    Posted 13 years ago on Sunday December 4, 2011 | Permalink
  2. I would add a radio button before those fields show up, asking if you want to "upload or add URL" - then, with conditional logic, show the upload field for one choice and the URL field for the other choice. Make all 3 fields required (the decision, the URL field and the upload field) and with conditional logic, the one required but hidden field that is not being used will not trigger a validation error even though it's empty. It's not really counted.

    Does that work well enough for you?

    Posted 13 years ago on Sunday December 4, 2011 | Permalink
  3. Lea Cohen
    Member

    Hi Chris,

    Thank you for your suggestion. I think it might be a good solution (I still have to consult our designer for any design issues), but it's not working....
    I added the radio button field, and then applied the conditional logic to the upload file field. But then when I open the form - all I get is a blank page...

    Posted 13 years ago on Sunday December 11, 2011 | Permalink
  4. If you are getting a blank page, chances are it's a 500 Internal Server error, and probably not related to the conditional logic. If you have access to server logs, you should be able to see what error is being recorded and triggering the blank page.

    Please post a link to your form if you would like us to take a look at it. But if it is an Internal Server Error, you will need to display errors or enable logging and see what the error actually is. The blank page just tells you there was a problem processing the php code.

    Posted 13 years ago on Monday December 12, 2011 | Permalink
  5. Lea Cohen
    Member

    Ok, I found the problem. I had made a dedicated Page template, and had neglected to call wp_head(). Now I called it, and the page loads fine. Thank you!

    Posted 13 years ago on Monday December 12, 2011 | Permalink
  6. There you go. Thanks for posting your solution. It will serve as a good reminder to include wp_head(). Thanks and have a good day.

    Posted 13 years ago on Monday December 12, 2011 | Permalink

This topic has been resolved and has been closed to new replies.