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

Reset Form Button interrupted by other validation code.

HankS
Registered: Apr 17 2009
Posts: 15
Answered

I have a form with a lot of javascript that I am using for validation. For instance, I have code that fires after a field is populated and it sets focus on another field and makes it required. If populated, the code will make the field not required and vice versa. This all works great.

The issue is that if the required code script is fired on the form and I need to reset the form, the button will reset the form, however, I get popup messages from my previous validation scripts . If I click"ok" through these messages the form will eventually reset, however, this is not ideal.

Is there an easy way to reset the form without any other code firing on the reset?

My Product Information:
Acrobat Pro 9.3.1, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Since you've got a lot of script, with a lot of popup messages, you'll need to setup the reset to take all this into account.

One option, and probably the best one is to make sure the reset value (i.e, the default value for the field) does not trigger the validation, so it all flows naturally. If you can use this option then your form will work no matter how the form is reset.

Another option is to use a variable, defined at the document level to block validation during reset. So your reset button code might look like this.

bBlockValidation = true;
this.resetForm();
bBlockValidation = false;

Then "bBlockValidation" is used in the validation scripts.

And then another option is to write your reset script to reset each field individually in way and order that is necessary for the form to act nicely.

Both of the last two solutions are a bit messy and they require that the user reset the form using the reset button.

And you might have another potential problem. How does your form handle imported data?

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

HankS
Registered: Apr 17 2009
Posts: 15
Thanks for the advice.

I am going to go with the first option since the other two options may require a lot of changes. I wont be importing any data into the form so that will not be an issue.