Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Javascript to highlight textfield2 if the contents don't match textfield1?


Level 1

After two years being away from what little I learned about Livecycle 8, I'm back and have a need to do a little Javascripting. It's rough going on my end.

Can anyone provide an example of a javascript code that would do the following:

I have two text fields. Textfield1 and Textfield2.

Upon exiting Textfield2, I would like the form to check to make sure that what was just entered in Textfield2 matches exactly what was previously entered into Textfield1.

If the values (text) don't match, I'd like Textfield2 to highlight red upon exiting. (Or any color other than the default light blue that is seen when the form is viewed in Adobe Reader)

The text entered into both fields will occasionally be different (and sometimes even be numerical - which is why I'm using the Text Field object to include both), so I would like to avoid an annoying popup message or any function that forces the two text fields to match (such as using the global function to populate the second field based on the first).

There is no display pattern formatting being enforced on the text object. The user is free to type whatever they want into the textfield. I need to avoid forcing a specific formatting on what is entered into either field - just want to highlight one of the fields when they don't contain exactly the same thing.

My goal is to bring the field differences to the user's attention with a visual "Are you sure you typed that correctly?"

I think highlighthing one or both of the fields if they don't match would be a perfect, non-obtrusive way to do that without slowing the user down or interrupting their flow.

Does anyone have some Javascript experience in doing this? I'd greatly appreciate seeing how you did it.

Thanks much.


0 Replies