Making all hidden fields optional | Community
Skip to main content
Level 2
May 16, 2022

Making all hidden fields optional

  • May 16, 2022
  • 1 reply
  • 1166 views

Hi all!

 

This is related to a previous question that I've asked, but I think I narrowed things down quite a bit. I have a script (Fragment) that runs on submission that scans the form and makes all hidden-required fields optional, that way the form will submit as long as all of the visible required fields are filled. This script worked really well on PDF forms, but I'm transitioning to .xdp (HTML5 rendered) forms. 

 

I'm having 1 key issue. Whenever I try to change a hidden field to optional, the script crashes. My initial fix was to, in the script code, make the field visible, make it optional, then make it hidden. This briefly worked but now is broken for some unknown reason. It makes the user push submit twice before submitting, obviously not great from a user experience standpoint.

 

Is there a known way to make a hidden field optional in a script? This seems like something that lots of people would want to do, but I can't find anything about it which leads me to worry that maybe I'm missing something obvious. Thank you for any advice you can give!

 

Respectfully,

John

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

1 reply

Mayank_Gandhi
Adobe Employee
Adobe Employee
May 17, 2022

@johnsolomon0 instead of making the field required you can actually prefer this logic:

if(field visible==true){

//check if the value is not null.

TextField1.validate.nullTest = "error";

}

You can also use one of these two scripts:

    TextField1.mandatory = "error"  
    TextField1.mandatoryMessage = "this field is mandatory!" 

https://help.adobe.com/en_US/livecycle/10.0/DesignerScriptingBasics/WS92d06802c76abadb57cc1b6e12a92343946-7ff8.html

Level 2
May 17, 2022

Hi Mayank,

 

I have way too many hidden required fields across my implementation of Webforms for it to be reasonable to go in and do that logic on each one of them. I need a way to solve this in a fragment script. 

 

I've tried using that bit

TextField1.mandatory = "error"  

but when I try and do that to a hidden field it doesn't work. 

 

I engaged Adobe support and we found a workaround, but I'm still confused as to why that doesn't work. 

Mayank_Gandhi
Adobe Employee
Adobe Employee
May 17, 2022

"we found a workaround," and that doesn't work? I am a bit confused so how is that a workaround or is it not consistent?