SOLVED

Re: Can I make a fieldset required in a form?

Go to solution
Anonymous
Not applicable

Can I make a fieldset required in a form?

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

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Can I make a fieldset required in a form?


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.

View solution in original post

6 REPLIES 6
SanfordWhiteman
Level 10 - Community Moderator

Re: Can I make a fieldset required in a form?

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?

Anonymous
Not applicable

Re: Can I make a fieldset required in a form?

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.

subscription center pic.JPGsubscription center pic2.JPG

SanfordWhiteman
Level 10 - Community Moderator

Re: Can I make a fieldset required in a form?

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.
remyburnaugh
Level 1

Re: Can I make a fieldset required in a form?

Hi Sanford,

 My apologies for responding on such an old post. This is the only thread I could find on the subject.

 

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? 

 

Thank you! 

SanfordWhiteman
Level 10 - Community Moderator

Re: Can I make a fieldset required in a form?


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.

remyburnaugh
Level 1

Re: Can I make a fieldset required in a form?

Thank you very much, Sanford! I'll take a look at it.