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

How to block the 'save' function when the required fields are not fill

randybear
Registered: Feb 17 2010
Posts: 6

Hello, Everyone

I am new for this scripting. My question is:

How to block the 'save' function when the required fields are not filled?

I designed a PDF file with some required fields and I do not want the user to save the document until all required fields are filled. My idea is to write some scripts in Willsave method like:

if (this.getField("Family Name").value == ""){
app.alert('You should fill the Family Name field firstly!');
}

But I do not think it works as finally the document is saved after all.

Please help me on that!

So much thanks.

My Product Information:
Acrobat Standard 9.0, Windows
Float
Registered: Aug 15 2008
Posts: 20
Use the preSave event for this:

if (this.resolveNode("yourFiledName").rawValue == null){
xfa.event.cancelAction = true;
xfa.host.messageBox('You should fill the Family Name field firstly!');
}
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
The function cancelAction will only work for the events prePrint, preSubmit, preExecute, preOpen and preSign.
So it can't be used to abort saving the form.

The documentation in the "LiveCycle Designer Scripting Reference" for "cancelAction" is wrong.
Adobe confirmed this under this URL.
[url]http://livedocs.adobe.com/livecycle/8.2/wb_designer/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Adobe_LiveCycle_Designer_Help&file=001406.php[/url]

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

randybear
Registered: Feb 17 2010
Posts: 6
So is there any way to abort the 'save'?
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
No, this function can't be aborted.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

nh39
Registered: Feb 19 2010
Posts: 7
Maybe you have a good reason behind this, but why would you want to prevent users from saving the form? It makes more sense to me if you want prevent them from submitting/printing an incomplete form. What if the users can't complete the form in one sitting for whatever reason and have to shut down their computers.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Many form developers or providers do not want a partially completed form being processed by mistake. So they think that if the form is not saved, printed or submitted they have accomplished their goal.

I would add a filed or fields that is/are visible until all of the required fields are completed.

George Kaiser