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

clear field when data validation fails

silin
Registered: Nov 26 2009
Posts: 3

Hello !

(i apologize for my English)

I have a form with a date field. I use a validation model to prevent the possibility of entering incorrect date format (i don't want : 1 avril 2007 but : 01.04.2007 for ex).

When a false date is set, the validation model open a popup window which says the entered date is wrong... that' s correct, but i can go on and save the form, or fill the other fields with the wrong date.

How can i clear the date field when the date is wrong ?

(searched the answer for 2 days now...)

thanks a lot.

My Product Information:
LiveCycle Designer, Windows
joheim
Registered: Jun 29 2010
Posts: 3
Great question!!! I am looking for the same!
DaveyB
Registered: Dec 10 2010
Posts: 70
The answer is in hidden fields. I realise that that sounds a little vague, but bear with me a minute ...

Step 1: For each "required" field, create a hidden numeric field with a default value of zero. Create a validation script for the required field, checking the hidden field and adjusting its value. If the hidden field was zero and the required field validates, then the hidden field becomes 1, if the hidden field was 1 (previously entered correctly)and the required field does not validate, then the hidden field gets a value of zero, otherwise it remains at 1.

Step 2: Create a form level variable which contains the total number of required fields. Each time you add a required field, manually increment this number.

Step 3: In the pre-save event, add a script which will add together the hidden field values from the required fields, compare it to the total number of required fields, and then allow or abort the save of the document based on the result.

From the help file description: "You can use this event to change form data immediately before the data is saved. For example, you can create a script on the preSave event to scan the data and display a reminder message to the form filler if certain required fields remain empty."

Logic would dictate that there should be a way of checking that all of the form validation is correct before allowing a "save" or "print" action, but I haven't seen one yet, hence the kludge above. If anyone knows of a better way, I'd be happy to hear it!

**************************************
Afterthought: Create a second hidden field on each required field, with a default value of 1. Now, in step 2, you can sum these fields instead of setting a form level variable, and you can turn 'required' on or off on a field just by changing this one value.

Hope that makes some sense and is helpful!

DaveyB

LiveCycle Designer 8.0
"Genius is one percent inspiration, ninety-nine percent perspiration." ~~ Thomas Edison
"If at first you don't succeed, get a bigger hammer." ~~ Alan Lewis
"If the conventional doesn't work, try the unconventional" ~~ DaveyB