Can I make a fieldset required in a form? | Community
Skip to main content
September 9, 2015
Solved

Can I make a fieldset required in a form?

  • September 9, 2015
  • 1 reply
  • 4828 views

Is it possible to make a fieldset required? That is, I know I can make each field within a fieldset required, but to do so requires making every field required. I would like to make it so that at least one of the fields is selected before the person can go on and click the Submit button.

Thanks in advance for your help!

Laura

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

You say this is possible. While it may not have been the right approach for this person, are you able to share how this can be done? 

You can use a custom onValidate listener function.

 

When the person attempts to submit the form, Marketo first executes the native validator and then passes control to your custom validator code. Your code can see if the fieldset contains empty fields and then pop up the validation error accordingly.

1 reply

SanfordWhiteman
New Participant
September 9, 2015

The answer is Yes, but before I tell you how to do it, are you sure a fieldset is really what you want?  Semantically, a fieldset should hold related fields, but it's sort of like a form within a form.  The fields aren't necessarily interdependent.  Maybe you actually want a radio button set or checkbox set?

September 9, 2015

I am actually not sure that I want a fieldset...I tried to set the fields as radio buttons, but it seemed like I wasn't getting anywhere. To create a radio button set or checkbox set, does this require an overarching field and then fields within that? Here is the form that I'm working on. Or do I take one field and then create the values within that? I'm just a little lost on what the best approach would be...Thanks.

SanfordWhiteman
New Participant
September 9, 2015

This could be done w/3 fields:

  1. Subscription Status. Required.  Single-valued.  Values 'Daily', 'Weekly', or 'None'.  This should be a radio button set, b/c radio buttons automatically make it clear that only one current value is allowed.
  2. Unsubscribe Reason. Optional. Shown if Subscription Status = 'None'.  Multi-valued.Values 'Too many emails','Content not relevant,' etc.  This can be a set of checkboxes.
  3. Unsubscribe Comment. Optional.  Shown if Unsubscribe Reason = 'Other'.  Textbox.