PDF-Forms is a service provided by PDFzone.com | http://www.pdfzone.com/ __________________________________________________________________
When the field's value is 0 it is evaluating the same as "" Try something like this :
function restorme()
{
if (String(event.target.value) == "") {
event.target.value = event.target.defaultValue ;
}
}HTH, Jub
From: "kc" <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: <[EMAIL PROTECTED]> Subject: [PDF-Forms] Validation Script Question Date: Wed, 7 Apr 2004 16:50:32 -0500
RE: [PDF-Forms] Writing to external index filesHello List
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"?
Thanks in advance for any ideas on this.
Kenn.
Validation Script
if(event.value && event.value !== '0' && event.value.toUpperCase() !== 'NONE' )
{
percent = event.value.indexOf("%") != -1;
dollar = event.value.indexOf("$") != -1;
if (!percent && !dollar)
{
app.alert("Please include a $ sign or % sign with your coop number.")
// Add this, it will prevent from having an invalid value in the field:
event.rc = false;
app.beep()
}
else if(percent && dollar) //To check if the two are not present in the same value
{
app.alert("Please specify with only a $ sign OR a % sign with your numerals.",1,0);
event.rc = false;
app.beep();
}
}
Also on the same field I have this script on focus
function clearMe() { if (event.target.value == event.target.defaultValue) { event.target.value = "" ; }}
clearMe() ;
And this one one blur
function restorme() { if (event.target.value == "") { event.target.value = event.target.defaultValue ; } }
restorme() ;
_________________________________________________________________
Persistent heartburn? Check out Digestive Health & Wellness for information and advice. http://gerd.msn.com/default.asp
To change your subscription: http://www.pdfzone.com/discussions/lists-pdfforms.html
