prevent saving until they complete required fields

4,678 views
Skip to first unread message

aj

unread,
Dec 1, 2010, 12:18:33 PM12/1/10
to Adobe LiveCycle Developers
Is there a way to prevent the user from saving a Reader Extended PDF
form if they do not fill out my required fields? My dynamic pdf form
has two required fields. Once completed it has to be saved & the file
uploaded to a system. We wish to validate on the form before it
reaches the system upload process.

Currently, I place an alert box on the pre-save event, reminding them
to fill out the required fields before uploading the form, but is
there a way to prevent them from saving until the required fields are
completed? Can you send me the exact javascript code (if available)?

Thanks in advance!

-aj

Nithyanandam Dharmadass

unread,
Dec 1, 2010, 3:14:58 PM12/1/10
to live...@googlegroups.com
You can do that !

write your validation logic at the preSave event. If you do not want to save the form (in case the required validation failed), call the following line to avoid saving.

xfa.event.cancelAction = true;

Hope this may help you!
Nith


--
You received this message because you are subscribed to the Google Groups "Adobe LiveCycle Developers" group.
To post to this group, send email to live...@googlegroups.com.
To unsubscribe from this group, send email to livecycle+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/livecycle?hl=en.




--
Regards,
Nith


---------------------------------------------------------------------------------------------------
The maximum strength of a chain is the strength of its' weakest link.
---------------------------------------------------------------------------------------------------

aj

unread,
Dec 2, 2010, 12:10:51 PM12/2/10
to Adobe LiveCycle Developers
Hi Nith,

I tried the javascript codes below on a preSave event, but the form
can still be saved in Acrobat. Am I doing something wrong?

if (this.rawValue == null)
{
xfa.event.cancelAction = true;
}

if (this.rawValue == null)
{
xfa.event.cancelAction = "true";
}


On Dec 1, 3:14 pm, Nithyanandam Dharmadass <nith....@gmail.com> wrote:
> You can do that !
>
> write your validation logic at the preSave event. If you do not want to save
> the form (in case the required validation failed), call the following line
> to avoid saving.
>
> *xfa.event.cancelAction = true;*
>
> Hope this may help you!
> Nith
>
>
>
>
>
> On Wed, Dec 1, 2010 at 8:18 PM, aj <awe...@gmail.com> wrote:
> > Is there a way to prevent the user from saving a Reader Extended PDF
> > form if they do not fill out my required fields?  My dynamic pdf form
> > has two required fields.  Once completed it has to be saved & the file
> > uploaded to a system.  We wish to validate on the form before it
> > reaches the system upload process.
>
> > Currently, I place an alert box on the pre-save event, reminding them
> > to fill out the required fields before uploading the form, but is
> > there a way to prevent them from saving until the required fields are
> > completed?  Can you send me the exact javascript code (if available)?
>
> > Thanks in advance!
>
> > -aj
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Adobe LiveCycle Developers" group.
> > To post to this group, send email to live...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > livecycle+...@googlegroups.com<livecycle%2Bunsubscribe@googlegroups­.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/livecycle?hl=en.
>
> --
> Regards,
> Nith
>
> ---------------------------------------------------------------------------­------------------------
> The maximum strength of a chain is the strength of its' weakest link.
> ---------------------------------------------------------------------------­------------------------- Hide quoted text -
>
> - Show quoted text -

Nithyanandam Dharmadass

unread,
Dec 2, 2010, 2:00:30 PM12/2/10
to live...@googlegroups.com
I am sorry, the Adobe documentation explains the following limitation about this property:

This property applies only to the following scripting events: prePrint, preSubmit, preExecute, preOpen, and preSign.

So, we must find another way to prevent saving document. I will share if I find any solution.

Nith

To unsubscribe from this group, send email to livecycle+...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/livecycle?hl=en.




--
Regards,
Nith


---------------------------------------------------------------------------------------------------

The maximum strength of a chain is the strength of its' weakest link.
---------------------------------------------------------------------------------------------------

David Liao

unread,
Dec 2, 2010, 2:47:30 PM12/2/10
to live...@googlegroups.com
How is submission happening? Via a button or people just email these things?

User wanting to save prior to completing an entire form makes sense.
They may not want to fill out an entire form in one sitting. A better
bet is to guard against submission when the data is incomplete. There
are a number of approaches for that.

1. If you are submitting via a button, guard in the pre-submit event.
2. If you have an email endpoint waiting for an email to come in,
validate data on the server, if incomplete, then send it back to them.
3. If user is printing these out, have the guard at the prePrint event.

Hope that helps.

David

> --
> You received this message because you are subscribed to the Google Groups "Adobe LiveCycle Developers" group.
> To post to this group, send email to live...@googlegroups.com.
> To unsubscribe from this group, send email to livecycle+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/livecycle?hl=en.
>
>

--
David Liao

Duane Nickull

unread,
Dec 2, 2010, 2:53:03 PM12/2/10
to Adobe LiveCycle Developers
Or simply make the submit button disabled and if they click it it gives them the errors (“Filed 4 is mandatory”).

Duane

---
Adobe LiveCycle Enterprise Architecture - http://www.adobe.com/products/livecycle/
TV Show - http://tv.adobe.com/show/duanes-world/
Blog – http://technoracle.blogspot.com/
Music – http://22ndcenturyofficial.com/
Twitter – http://twitter.com/duanechaos/
“That’s all I have time for”

aj

unread,
Dec 7, 2010, 3:26:20 PM12/7/10
to Adobe LiveCycle Developers
The completed pdf form is attached in an email and submitted that
way. It does not use a button to submit the form because a user may
not click the button at all. That's why I was trying to make them
complete the required fields before saving. I guess that cannot be
done as stated earlier as the property applies only to the following
scripting events: prePrint, preSubmit, preExecute, preOpen, and
preSign.

The best I can do for now is to put an alert box up on the pre-save
event to "remind" them to complete the required fields. If anyone
thinks of another way to force the user to fill out required fields,
before the form can be saved and attached in an email...please let me
know. I'd really appreciate it.

-aj


On Dec 2, 2:53 pm, Duane Nickull <dnick...@adobe.com> wrote:
> Or simply make the submit button disabled and if they click it it gives them the errors ("Filed 4 is mandatory").
>
> Duane
>
> > For more options, visit this group athttp://groups.google.com/group/livecycle?hl=en.
>
> --
> David Liao
>
> --
> You received this message because you are subscribed to the Google Groups "Adobe LiveCycle Developers" group.
> To post to this group, send email to live...@googlegroups.com.
> To unsubscribe from this group, send email to livecycle+...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/livecycle?hl=en.
>
> ---
> Adobe LiveCycle Enterprise Architecture -http://www.adobe.com/products/livecycle/
> TV Show -http://tv.adobe.com/show/duanes-world/
> Blog -http://technoracle.blogspot.com/
> Music -http://22ndcenturyofficial.com/
> Twitter -http://twitter.com/duanechaos/
> "That's all I have time for"- Hide quoted text -

Kristensen RGA

unread,
Jan 6, 2011, 7:56:46 AM1/6/11
to Adobe LiveCycle Developers
I use this script on the click event of my print button.
var txt = form1.execValidate();
if (txt == true){
xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 1, 0, 0,
0);
}

And this one on the prePrint to prevent printing when not all required
fields are filled:

var txt = form1.execValidate();
if (txt == true){
}

It might work on the preSave event as well but you will have to test
that.

But I think that Acrobat/Adobe Reader's build in functions file>print
(ctrl+p) and file>save (ctrl+s) cannot be blocked from the form. You
will probably have to encurrage the user to use the buttons in the
form.

Kirstine
Reply all
Reply to author
Forward
0 new messages