PDF-Forms is a service provided by PDFzone.com | http://www.pdfzone.com/ __________________________________________________________________
A few comments:
• I assume that you have defined the functions on document level, and simply call them from within the fields. Otherwise, it is not really necessary (and useful) to define a function on field level and calling it immediately after the definition.
• In the Validation script, you might have to force event.value type to String, although with the construct chosen, a type discrepancy will fail to the "safe side".
• Although variables can be defined by their name only, it is highly recommended to define a variable with the var statement, such as in
var percent = event.value.indexOf("%") != -1;
• In the restoreMe() function you are essentially looking for the empty field. Because of the loose-typedness of JavaScript, "" (the empty string) can also be interpreted as 0. Therefore, you would be on the safer side to check for the length of the event.value, such as in:
if (event.value.toString().length == 0)
Hope, this can help.
Max Wyss PRODOK Engineering Low Paper workflows, Smart documents, PDF forms CH-8906 Bonstetten, Switzerland
Fax: +41 1 700 20 37 or +1 815 425 6566 e-mail: mailto:[EMAIL PROTECTED] http://www.prodok.com
[ Building Bridges for Information ]
______________________
Shameless Plug:
My next conference appearances and workshops:
• Conference presentations at the 2004 Symposium of the BFMA, May 23 to 27 in Reno, Nevada (http://www.bfma.org) and pre-/post-conference workshop, May 22/23 and 27, organized by essociates Group (http://www.essociatesgroup.com/AdvancedAcrobatForms.htm)
• And, as always, available for on-site workshops/tutorials/consulting.
_________________________
I use the following scripts on a field. The first (larger) script is a validation script to ensure that the user enters a "%" or "$" with the value that that they enter. I want the script to allow the user to enter the word "none" or the number "0" without requiring the "%" or "$".
There are also two other scripts on this field one on focus and one one blur. Their job is to wipe out the default text on focus, or restore it if the user does not type anything when leaving the field.
The validation script works fine, it does not require a "%" or "$" with "none" or "0". The focus/blur scripts work fine with the word "none". If they type "none" in the field, it remains. However if the user has typed a "0", the blur script restores the field to the default value. Can someone tell me why the scripts work fine for the word "none" but hiccup on the number "0"?
To change your subscription: http://www.pdfzone.com/discussions/lists-pdfforms.html
