Expand my Community achievements bar.

SOLVED

How to limit message box to appear only once not multiple times

Avatar

Level 1

Hi,

I am using the following script that makes a message box appear. The problem is that people are complaining that the message box appear multiple times and that you have to continusly click ok like 11 times for the "warning javascript window" message box to go away.

Can I use a different script or reduce the amount of times that the message box appears?

if (this.rawValue > 132) {

          xfa.host.messageBox("Maximum Sick Time is 132");

          this.rawValue = 132;

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

I am not sure how to do this but if  this field has any dependent field using which it is calculeted, then the dependent field could be used to set the value and subsequently show the pop up message.

View solution in original post

8 Replies

Avatar

Level 2

Hi,

In which event does this piece of code lie in? Is it within a function, then could it be that the function gets called repeatedly ?

Regards,

Ber

Avatar

Level 1

Hi Ber,

Thanks for responding.

The event is validate and the language javascript. I am not sure why the message box appears so many times. I hope we can find out why.

Thanks again!

Avatar

Employee Advisor

The validate event might cause the script to run multiple times here. You can use any other event to notify the user for the threshold value.

Please have a look at the flow.

Flow.jpg

Thanks

Avatar

Level 1

Hi Wasil,

I removed the script from the validate event and now the message box comes up only once, but only if I actually click on the field. The field that has the threshold value is automatically calculated so people do not click on this field, therefore, the message box will not appear for them. In addition, the number does not automatically go to 132.

I tried putting the script in other events but the script does no funciton properly.

Which event do you recommend?

Avatar

Correct answer by
Employee Advisor

I am not sure how to do this but if  this field has any dependent field using which it is calculeted, then the dependent field could be used to set the value and subsequently show the pop up message.

Avatar

Level 2

I see. What is the trigger that you want for such a validation? Is it on click of a button, or on exit of this field? If its on exit, have you tried placing the code in the 'Exit' event instead?

Avatar

Level 1

Hi Wasil,

I moved the script to the dependent field and placed the following script and it worked! Now the message box only appears once. I put it in the calculate event.  Thanks!

if ( topmostSubform.Page1.Text19.rawValue > 132) {

          xfa.host.messageBox("Maximum Sick Time is 132");

         topmostSubform.Page1.Text19.rawValue = 132;

}

Avatar

Level 1

Thanks Bern87 for trying to help. I appreciate it.