Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I tried to add something in the Save Button, so that they are forced to fill in those fields. Is it possible?
Copy link to clipboard
Copied
What button?
The button on the tool bar?
Just because you create a custom button that saves a PDF does not prevent users form using the Menue "File => Sava as.." or the Saver or Save AS ... button on the fool bar. To have something work with them you need to add custom JavaScript to the "Wiil Save" document action. If you create a custom button then you need to write custom JavaScript so all the code and the conditional statement is all within the scope of that block of code.
Copy link to clipboard
Copied
can you please let me know what the javascript code should be for the save button that i created?
I have created a button to Save As the pdf as new one. I want whenever user will hit the save button, they will get the warning that, required field is blank.
Hope you will suggest me.
Thanks
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
// 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.
Copy link to clipboard
Copied
Actually I am not familiar with this. I am using Acrobat XI Pro. Can you please help me to create this action?
I have a question regarding the script, Should i need to change the fields name here? I think i have to change the name
------------------------------------------
"Check Box2",
"Dropdown1",
"Group1",
"List Box4",
"Text1"
---------------------------------------------
Sorry for making this confused.
Thanks
Find more inspiration, events, and resources on the new Adobe Community
Explore Now