Expand my Community achievements bar.

Radio Buttons & Mandatory Fields

Avatar

Former Community Member

Hello,

I have a radio button with  2 options. Yes and No. When the  user chooses Yes a hidden form appears. When they Choose No, the first subform will be hidden and the new option will appear. This radio button is in a hidden subform. If the subform is not opened, all the required fields are hidden and not recognized when the user hits submit.

If however, the user opens the hidden subform, and fills in the info for the Yes or No radio button, and then they decide that they didn't need to fill in that section, and they uncheck that subform, the subform is then hidden. The problem is that when hitting submit once the form is hidden, the fields which are mandatory under the Yes and No radio button stays visible therefore, the required fields are not being disabled.

I'm not sure how to fix this. Can anyone help?

7 Replies

Avatar

Level 10

Hi,

You can sort this by including script that changes the objects from 'required' to 'optional', using the mandatory property.

In the script that changes the visibility of the subform, add in the following to turn off required (eg when the subform is hidden):

objectReference.mandatory = "disabled";

When changing the presence to visible, the following will make the field mandatory again:

objectReference.mandatory = "error";

Hope that helps,

Niall

Assure Dynamics

Avatar

Former Community Member

Hi Niall, thank you for your response. I am using that script but Its still not working.

I think I need to be more specific. there is a checkbox asking the user what kind of change they need to make. one of the options is 'change of address'. So they click on Change of Address and a hidden form appears. they enter the address and it then asks 'is your residential address different from your mailing address?'. This is a yes or no radio button. If the user chooses Yes, then another yes or no radio button pops up. It then asks them another yes or no question. So if the user chooses yes one option comes up and if the user chooses no a different option shows up. if  the user at this point decides that they dont want to do a change of address, and they uncheck the address check box the form will be hidden. But I believe what is happening is that the second radio button is staying visible, therefore the required fields in the subforms linked to that set of radio buttons are being recognized as required, when you hit submit.


Sorry for the long explanation. I hope that makes sense.

Thank you,


Nik

Avatar

Level 10

Hi,

Here is an example that may help you:

http://www.assuredynamics.com/index.php/category/portfolio/changing-the-mandatory-property/

Basically any script that changes the presence of required fields needs to be extended. When you hide a required field, you should first set its mandatory property to 'disabled'. This will make the field optional and therefore the submit button will work.

One thing to watch out for is to set the mandatory property first and then the presence property.

Hope that helps,

Niall

Assure Dynamics

Avatar

Former Community Member

I tried it but its not working. its likely because I really don't know javascript well. I just know what I've learned through this website. I think its just beyond my scope of knowledge. Thank you for your help though.

Avatar

Level 10

Do you want to post your form (or the part giving you trouble) to acrobat.com and post the published link here?

Niall

Avatar

Former Community Member

I'm not sure how to do that. i've always just sent the form by email