Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Text and Numeric Fields - Keeping the previous value.

Avatar

Former Community Member

Greetings all!

Here is what is happening:

First of all working in Designer ES2 9.0.0.2.2.... with Adobe Acrobat X Pro 10.1.0.

Here is what I am attempting:

Text field to capture a ZIP Code.

Using a Reg Exp to only allow the input of digits - I do this because the client wants to add a hyphen '-' automatically after the 5 digit IF the user enters a 6th+ digit.

When the user exits the field I am firing a simple if statement to look at the length of the rawValue in the field.

IF the value is not 5 or 9 characters throw a message box that asks the user to enter a valid ZIP code.

setFocus back to he field.

Simple enough...However.

If the user makes a second mistake on entry:

First entry = 12345-689  So they forgot the last digit

Error message throws.

Second entry = 12345-690 So they missed the "8".

When the Error message fires again the field will show 12345-689, the first entry.

When the user closes the Error message and the setFocus fires the entry reverts to the Second entry of 12345-690.

The client finds this behavior confusing.

Anyone have an explanation of what is happening AND a potential solution?

Thanks and regards,

Rick Kuhlmann

3 Replies

Avatar

Level 6

Right that is how it behaves....First let us check the sequence the events fire with data entry and exit events.

First event that gets fired is Validation....then Exit.... and then the value get set to the field.

So with first instance of error till all the events are fired the value in the Zip would be 'null', so nothing will be noticed while those messages are displayed.

But at the end of the event sequence Zip value is set to '12345-689' and that is what carried till the next value is set to that field and gets displayed in the field while messages are popped during the second round of error sequence. And at the end of completion of event sequence the new value is set to the field causing that to display in the field.

Just to review this theory all you need to do is modify your messages to show like the following......JS code

xfa.host.message("your message goes here " + "Current value of the field:" + this.rawValue);

and then run through the entire scenario you would notice the difference....

Good luck,

Avatar

Former Community Member

Varma_LC,

Thanks for the information. However, I want to be clear as to what code is firing in which events.

1. There is a Reg Exp in the change event that watches the xfa.event.newText. That limits the user to digits only. In this code there is also another Reg Exp that looks for the a 5 digit run of entries so that it can place the hyphen after the 5th digit.


2. The "validation" happens in the exit event.


If I am understanding you correctly the value of the entry does not get set into the field until the exit event has completed. So even if someone enters new data into a field that was previously populated that newly entered data must wait for the exit event to complete before it is set to the rawValue of the field.


I have tried your suggestion to place the value of the newly entered data into a message but the field will still display the old value.


Thanks for your time!

Avatar

Level 6

Yes...newText is still in the memory not set as rawValue until all the events are fired and curser exits the field.

The purpose of my code is to prove you this theory. If you like to review/use current entry you should always use xfa.event.newText so if you wish you can add following code in your change event validation witch will force the field to accept the newText as rawValue....

this.rawValue = xfa.event.newText; //position this appropriately in your code...this should happen when the validation in change event passes....

Hope that helps...