These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Making fields un required if the are hidden:

brennanhobart
Registered: Oct 9 2007
Posts: 37
Answered

Making fields un required if the are hidden:
I have some required fields that are visible when users click radio payment options, otherwise hidden. I need to have those hidden required fields become un required, so the form submits. I have tried everything I can think of and can not figure out how to make them un required when hidden. Here is the code javascript
I’m using:
  
// moCode radio button
 
EmailSubmitButtonM.presence = "visible";
MoCode.presence = "visible";
AuthMoCodeSignatory.presence = "visible";
AuthSignEmail.presence = "visible";
EmailSubmitButtonU.presence = "hidden";
UniCardNumber.presence = "hidden";
AuthUniCardSignatory.presence = "hidden";
ExpDate.presence = "hidden";
  
// Unicard radio button
 
EmailSubmitButtonU.presence = "visible";
AuthUniCardSignatory.presence = "visible";
UniCardNumber.presence = "visible";
ExpDate.presence = "visible";
EmailSubmitButtonM.presence = "hidden";
AuthMoCodeSignatory.presence = "hidden";
AuthSignEmail.presence = "hidden";
MoCode.presence = "hidden";
 
Thanks, Brennan

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
In Acrobat 8 the field's "mandatory" property controls whether or not the field is required. Look it up in the XFA Form Object Model Reference.

EX:

EmailSubmitButtonM.presence = "hidden";
EmailSubmitButtonM.mandatory= "error";

ExpDate.presence = "visible";
ExpDate.mandatory= "disabled";

This is a little differnt in Acrobat 7

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Nope, I just checked, it's the same in Acrobat 7.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

brennanhobart
Registered: Oct 9 2007
Posts: 37
Thom,

Thanks for your response.

Since I have two different submit buttons that appear and disappear, I put the code below
I put

MoCode.mandatory="disabled";
AuthSignEmail.mandatory="disabled";
AuthMoCodeSignatory.mandatory="disabled";

in the preSubmit event of one submit buttons. It's working good because even after the user changes payment options nothing is disabled until right before they submit, otherwise it was disabling and not reactivating the required fields.

Thanks, again. Brennan