Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How do I make a field visible if the value in three textboxes don't match?

Avatar

Level 2

Hello Experts.

I have a form with three textboxes.  I would like a warning box to display when saving warning the user that "These amounts don't match!".  I would also like a textbox to become visible when saving  the document, and to remain visible in the layout until the amounts match.  I don't want to prevent the user from saving the document, I just want them to know that there are possible errors.

I would like to use something like the following:

if textbox1 != textbox2 !=textbox3

{textbox4.presence="visible";}

Also, have a message box pop-up when saving like the following:

xfa.host.messageBox("These amounts don't match!","Title",2);

My question is how do write this, and what events do I use for this?

Any help is greatly appreciated.

Thanks,

Jerald

1 Accepted Solution

Avatar

Correct answer by
Level 10

Place the below code in the preSave event of any control..

Language is Java Script

if (textbox1.rawValue != textbox2.rawValue !=textbox3.rawValue){

     xfa.host.messageBox("These amounts don't match!","Title",2);

     textbox4.presence="visible";

}

else{

     textbox4.presence="invisible";

}

Also place the same code in the exit events of al lthe thre text fields (textbox1,textbox2 and textbox3)..

Thanks

Srini

View solution in original post

4 Replies

Avatar

Correct answer by
Level 10

Place the below code in the preSave event of any control..

Language is Java Script

if (textbox1.rawValue != textbox2.rawValue !=textbox3.rawValue){

     xfa.host.messageBox("These amounts don't match!","Title",2);

     textbox4.presence="visible";

}

else{

     textbox4.presence="invisible";

}

Also place the same code in the exit events of al lthe thre text fields (textbox1,textbox2 and textbox3)..

Thanks

Srini

Avatar

Level 2

Thanks again Srini.  I'm having a slight problem with this, but I don't think it's the script.  I get the message box,  and textbox4 becomes visible when the amounts don't match.  Unfortunately, even when the amounts in the textboxes are equal I still get the message box and textbox.  If it's an issue with the formulas I'm using to calculate the totals in textboxes 1, 2, and 3 I'll open another discussion identifying this as a possible problem.  If you think it's an issue with this script, let me know if you have any other suggestions.

The default value of all fields involved is "0".  So, when I open the form all of the textboxes display "0".  However, textbox4 remains visible even though textboxes 1, 2, and 3 all have the same value of "0".

Thanks,

jerald

Avatar

Level 4

Just set field4 to be hidden or invisible by default then have the values of 1, 2, and 3 control it's presence.