Skip to main content
csbfprepress
Participant
May 17, 2017
Answered

Required Field becomes Not Required when Checkbox is Checked

  • May 17, 2017
  • 2 replies
  • 1266 views

I have a form that needs several required fields. However, when a certain checkbox is checked,

some of the fields are no longer necessary and need to become "not required" anymore.

Is there a way to do this? I'm not sure if it's even possible. If it is, it may require a java script.

I'm currently using Adobe Acrobat 8 Professional version 8.0.0 on Mac OS 10.5.8

I also have access to Adobe LiveCycle Designer ES4 on Windows 7

This topic has been closed for replies.
Correct answer Joel Geraci

Yes. It's possible. You don't have any field name details though so I can't give you specific code but you just need to set the field required property to true or false. You code might look something like this.

this.getField("foo").required = false;

2 replies

Inspiring
November 6, 2020

I have a similar question, but I'm not using a Mac.

Needing to have a second field as a required entry after checkbox checked.  I can get this to work for the first field but not the scond one.  I need the second field, "Date Entered" to also be a required entry.  Below is the script for the first field:

var v = this.getField("Name of Facility");

var f= event.target;

if (f.value !="Off") {

v.required = true;

} else {

v.required = false;

}

 

Thanks in advance for your help.

Joel Geraci
Community Expert
Joel GeraciCommunity ExpertCorrect answer
Community Expert
May 18, 2017

Yes. It's possible. You don't have any field name details though so I can't give you specific code but you just need to set the field required property to true or false. You code might look something like this.

this.getField("foo").required = false;

csbfprepress
Participant
May 18, 2017

Thank you! Good to know it's possible.

The checkbox field name is "no previous employer" and one of the fields it needs to make not required is named "previous employer"

Can you tell me where I need to input the code to set the field required property?

Joel Geraci
Community Expert
Community Expert
May 18, 2017

Generally, if you want to change something in a field other than the one you're on after the user commits the value, you'd put it in the OnBlur script.