Expand my Community achievements bar.

PREVENT a form from being cleared? Or in the alternative, at least trigger a messageBox warning end-user this is a bad idea?

Avatar

Level 3

The "Clear Form" button located under "tools" > "forms" is great for that - clearing forms - but what if you don't want the end-user to accidentally click that button?  Is there a way to prevent or at least trigger a messageBox warning them they're about to lose all their work?

Designing in Livecycle, btw.

BR

8 Replies

Avatar

Level 10

Hi,

Try changing the code in the click event to something like;


if (xfa.host.messageBox("Are you sure?", "", 1, 2) == 4)


{


xfa.host.resetData();


}


Regards

Bruce

Avatar

Level 3

Hi Bruce,

Happy New Year and thanks for the reply.

That will be great for buttons I create and place on a form myself, so thanks!  

But what about the "Clear Form" button that is part of the Acrobat and Reader UI?  (On the right-hand side under Adobe's holy triumvirate  "Tools | Comment | Share" ? 

I'm using Acrobat 10.1.13, so for me, the "Clear Form" button is located under "Tools"> "Forms" and is positioned immediately below "Highlight Existing Fields" and immediately above "More Form Options".

Is it possible to access the click event of THAT UI button to use the code you suggested? 

I've got a bad work-around: a hidden field with a default value that clears when the Clear Form button in TOOLS>FORMS is clicked.  BUT the change event in that field has code to trigger a messageBox if the field's new text is null. messageBox essentially tells the end-user to close the form WITHOUT SAVING (to disregard the Clear Form action) and then re-open to continue on with the form.  Like I said, it's a bad work around but it at least gives them a chance to undo what they did.

Possible to just disable that button?  Or access the Clear Form's click event to use the messageBox warning you suggested BEFORE the information is all deleted?

Thanks much,

B

Avatar

Level 10

Hi,

Are you using LiveCycle Designer to create your form? If not there are better forums for you to try, maybe this one PDF Forms.

Regards

Bruce

Avatar

Level 6

Brian - I too wonder the same thing, but I doubt the designer is able to prevent usage of the system "Clear Form".

I have a case in which a password protected form field might be intentionally updated by an admin (i.e. a price change from the original default), and resetting the form would create issues in that the NEW price value would revert back the default. This would obviously create issues for a calculated total field being that the resulting amount would be based on an old figure.

For example:

Bike: $350 (default value), later updated to $300 (new sale value). If the form gets reset using the UI rest button, the amount would revert back to $300.

I think the workaround you've developed is doable (something I'm thinking about using), although the only kickback is that user will lose any work/time they've invested up until that point the form is reset. I wish there was a way to detect the UI Reset button click and inject a break (i.e. giving the user the option of continuing with the reset function or canceling - much like what is possible with a hand-placed or custom-programmed RESET button).

Shaun

Avatar

Level 3

Hey B,

Yup.  Using Livecycle for its dynamic properties vs static.

If it's not possible to access the click event of the "Clear Form" button that is part of the Acrobat or Reader UI, is there a way to use javascript to at least close the "Tools|Fill & Sign|Comment" side-bar when the PDF initially opens?  (Something like the "app.runtimeHighlight = false" script?) Sure, the end-user could still manually open the side bar and then find the Clear Form button it, but it would be something if the UI "Clear Form" can't be disabled and there's no way to create a "confirm clear" dialog for it.

Thanks,

B

Avatar

Level 3

Shaun,

Agreeing with you on many fronts; glad my work around might help you a little.  Better to lose a little work rather than all of it, I guess. But, it's still just a band-aid and not a real fix.

Can't believe it doesn't automatically ask the end-user if they're sure they want to clear the form.

B

Avatar

Level 10

Hi,

Sorry, I finally understand what you mean, but have no solution.  Does seem a strange thing to have when it is so easy to add a clear form button if one is needed.  But then I also haven't heard of it being a problem, it would totally break our forms as all of them rely on some level of pre-population.

Regards

Bruce

Avatar

Level 6

Brian,

One thing to note is that Adobe Reader users don't have access to the "Clear Form" button option*, so it's really the Acrobat users that could create issues. That being said, you could write a script to identify the application type and if "Acrobat" pre-warn the user on doc:ready not to use the Clear Form button. At least this could help prevent them loosing work and having to start over. If they still do it, then it's really their fault, but you'd still have to advise them to close the form since the pre-populated data is no longer good.

*Adobe Reader users are able to use clear forms by using: File>Revert, however, this method does does provide a warning asking if they want to revert back to the previously saved version. Luckily, I think you will find most end-users use Adobe Reader to complete forms so hopefully the problem isn't as widespread.