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

Script to make fields Required (in LCD)

Michael Frommer
Registered: Apr 3 2009
Posts: 80

I'm sure this is extremely basic but I dont see why this isnt working. Working in LCD 8.0.
If Field A is not null make Fields B,C,D & E required.
Field A is in a diferent subform than fields B,C,D,E.
I have this code on the Exit event of Field A (this).
The Object Value tab for fields B,C,D & E is set for "User Entered-Optional" .

if ((this.rawValue != null || this.rawValue != " ") && (this.rawValue.length > 0))
	{
	F1.P1.C2.Info.Firm.mandatory = true;
	F1.P1.C2.Info.Contact.mandatory = true;
	F1.P1.C2.Info.Phone.mandatory = true;
	F1.P1.C2.Info.Email.mandatory = true;
	}
else
	{
	F1.P1.C2.Info.Firm.mandatory = false;
	F1.P1.C2.Info.Contact.mandatory = false;
	F1.P1.C2.Info.Phone.mandatory = false;
	F1.P1.C2.Info.Email.mandatory = false;
	}

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Look here.

http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=22692

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Michael Frommer
Registered: Apr 3 2009
Posts: 80
I changed it as you suggested but it still dosen't work. (I could have sworn I read the string was either true or false.)

if ((this.rawValue != null) || (this.rawValue != " ") && (this.rawValue.length > 0)){F1.P1.C2.Info.Firm.mandatory = "error";F1.P1.C2.Info.Contact.mandatory = "error";F1.P1.C2.Info.Phone.mandatory = "error";F1.P1.C2.Info.Email.mandatory = "error";}else{F1.P1.C2.Info.Firm.mandatory = "disabled";F1.P1.C2.Info.Contact.mandatory = "disabled";F1.P1.C2.Info.Phone.mandatory = "disabled";F1.P1.C2.Info.Email.mandatory = "disabled";}
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Ok,

I tried it the same way you did, but didn't have a problem.

You should try to address the form field with the fully qualified SOM expression.

xfa.resolveNode("F1.P1.C2.Info.Firm").mandatory = "error";
Remember, the mandatoy method only works with the default send/mail-buttons of LCD, not for a regular button with a custom script.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Michael Frommer
Registered: Apr 3 2009
Posts: 80
Will it work with a default Print button?
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
I do't think so, because printing a form has to be always be possible.
So if the worst comes to the worst it can be filled manually and returned the old-fashioned by the postman.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Michael Frommer
Registered: Apr 3 2009
Posts: 80
I guess I'll need to use a regualr print button and script a validation prior to printing. I've started a [url=http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=22715]new thread here[/url] so I can put this into perpective.