Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Clear date field if validation fails

Avatar

Level 1

Hello,

I am using LiveCycle Designer version 8.2.1.  I have several date fields that the user can select the date from the calendar or enter the date manually.  The validation field is (MM/DD/YYYY).  Is there a way to clear the date field if the user inputs the wrong date format?  After the error validation message displays, the incorrect data remains in the date field.  I would like to make the date field blank if the date is inputted incorrectly until the date is typed in the correct format.

If this is not possible, is there a way to just make the user only use the calendar to select the date?

I am a novice user.

Thanks in advance!

2 Replies

Avatar

Level 8

For Designer/Reader 8 use in the exit event in FormCalc:

if (not Date2Num($.editValue,"MM/DD/YY")) then

$=null

endif

For Designer/Reader 9 and up in the validateState event in JavaScript:

if (this.errorText)

this.rawValue=null;

Kyle

Avatar

Level 2

A bit late adding a question to this thread but the script below works only for the first instance. If the end user fails validation a second time then the field is not cleared.

if (this.errorText)

this.rawValue=null;

Any suggestions?