Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Scripting error changing field required state


Not applicable
I need to update all fields in a document to be not required. I read the value but cannot set it. I get the following error in the debugger.

NotAllowedError: Security settings prevent access to this property or method.

Field.required:10:click undefined:Exec

According to the documentation, this should be easy to do.



Sets or gets the required characteristic of a field. When true, the fields value must be nonnull when the user clicks a submit button that causes the value of the field to be posted. If the field value is null, the user receives a warning message and the submit does not


Type: Boolean Access: R/W Fields: all except button.


Make "myField" into a required field.

var f = this.getField("myField");

f.required = true;


I am not sure what this means or how to correct. Any help would be greatly appreciated. My code is below.

var fieldCount =;

for ( var i = 0; i < fieldCount; i++)


var fieldName =;


var field =;

if(field.type != "button" &&

field.type != "checkbox")



field.required = false;


3 Replies


Not applicable
If you are designing your form in Designer and not Acrobat then you shouldn't be trying to change the property on the AcroForm object (ie: the fields you get from using but rather on the XFA object. Here is an example copied from the XML Form Object Model Reference that changes all fields to read only. You can modify this to achieve what you want. In your case you'll want to set the mandatory property to "disabled".

// Get the field containers from each page.

for (var i = 0; i <; i++) {

var oFields = xfa.layout.pageContent(i, "field");

var nodesLength = oFields.length;

// Set the access type.

for (var j = 0; j < nodesLength; j++) {

var oItem = oFields.item(j);

if (oItem != this) {

oItem.access = "readOnly";





Adobe Enterprise Developer Support


Not applicable
That helped. Thank you.

I have one more problem.

I have two buttons for submitting the form. One of the buttons (Complete) submits doing all validation. The other button (Save) submits but needs to turn of the mandatory field validation. I have tried putting this script in the click event of the Save button, but you cant have click event code in submit buttons. So my next option was to put the code in the preSubmit event. However, this fires for every submit. Is there a way to determine that the preSubmit event was caused by the Save button and not by the Complete button?


Not applicable
Does it work if you put the code to turn off the mandatory field validation on the mouseDown event of the save button?


Adobe Enterprise Developer Support