Skip to main content
New Participant
May 21, 2016
Question

How to force users to fillup text field, check box, dropdown option before saving

  • May 21, 2016
  • 1 reply
  • 799 views

I have a 2 pages pdf form which includes several required fields (text box, check box, dropdown optoin) and a save button.

I want the following actions to be happened before pressing "save as" button. (They can't save by pressing save button without doing the following actions)

1. Users must have to input data into the text field

2. Users have to select at least an option (if needed more than one) from the check box items

3. Users have to select an item from dropdown option from the list.

Thanks

This topic has been closed for replies.

1 reply

Inspiring
May 21, 2016

I would recommend against such an action since it could be so inconvenient for the user on a large form. You can add some indicator that required fields are not completed. in any number of ways like having a read only field displayed indicating the issue or have a layer with the warning visible. If you create the button for the "Save As" action you can prevent the saving but you cannot control the menu option 'Save' or 'Save as' nor can you control the tool bar buttons for save or save as.

The easiest way is to compare the "value" of the fields to the "defaultValue" of the field in some custom JavaScript code. The exact code would be dependent as to how you have set up the form and the field properties. Your form fields will need to have a default value that is not an acceptable "filled in" value. The "Required" property will only issue a warning when submitting the PDF to a URI address like a web page or a mailto action.

Cats_EyeAuthor
New Participant
May 21, 2016

I tried to add something in the Save Button, so that they are forced to fill in those fields. Is it possible?

Inspiring
May 22, 2016

There are more than one text field, and some check boxes also available there,

so, all i need will be control over all the field in the save button.

Thanks


// document level scripts;
function GetField(oDoc, cName)
{
var oField = this.getField(cName);
if(oField == null)
{
  app.alert("Error accessing field \""+ cName + "\".\n Please check for field name", 1, 0);
}
return oField;
} // end GetField function;

GetField(this, "IncomplereFelds").display =  display.hidden;

// array of names for the requreid fields;
var MyRequired = new Array(
"Check Box2",
"Dropdown1",
"Group1",
"List Box4",
"Text1"
);

function CheckRequired(aRequired)
{
var aIncomplete = new Array();
var oFieldi
for(var i = 0; i < aRequired.length; i++)
{
  oFieldi = this.getField(aRequired);

  if(oFieldi.value == oFieldi.defaultValue && oFieldi.type != "button" && oFieldi.type != "signature")
  {
   aIncomplete.push(oFieldi.name);
  }
}
if(aIncomplete.length == 0)
{
  app.alert("All required fields completed.", 3, 0);
  // other code for all requried complete;
}
else
{
  app.alert("Not all required fields have been completed!", 0, 0);
  // additional code for incomplete fields;
}
return (aIncomplete.length == 0);
} // end CheckRequired;
// end document level scripts;

Code to test button mouse up action.

GetField(this, "IncomplereFelds").display =  display.hidden;
if(CheckRequired(MyRequired) == false) {
GetField(this, "IncomplereFelds").display =  display.visible;
} else {
// code if all requried fields are completed;
}

You can use the test button code for the "Will save" and "Will print" docuemnt actions.