Expand my Community achievements bar.

SOLVED

Validation message for reset button

Avatar

Former Community Member

Hello,

I would like to have a validation message pop up when a user presses the reset button. I would like it to read something like,

     "Pressing this button will reset table data. Are you sure you would like to proceed?"

Thanks,

Wes

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Wes,

You can send a message pop-up in the click event of the reset button using xfa.host.messageBox();

To be able to ask a question in order to receive an answer and then execute code you must specify the right parameters in that function.

e.g.

var answer = xfa.host.messageBox("Pressing this button will reset table data. Are you sure you would like to proceed?", "Reset Form", 2, 2);

if (answer == 4){

     xfa.host.resetData();

}

You can have various answers with the messageBox depending on what kind of options you give to the user.

In the function messageBox() after "Reset Form": The first integer which is '2' is there to show the image you want to display, e.g. :

0:"X",

1:"!",

2:"?",

3:"i"

The second integer is to specify which buttons you want to display, e.g.:

1: Ok Cancel

2: Yes No

3: Yes No Cancel

4: Ok

The function messageBox() then returns an integer which results in the answer of the user, e.g.:

1 = Ok

2 = Cancel

3 = No

4 = Yes

View solution in original post

4 Replies

Avatar

Correct answer by
Level 10

Hi Wes,

You can send a message pop-up in the click event of the reset button using xfa.host.messageBox();

To be able to ask a question in order to receive an answer and then execute code you must specify the right parameters in that function.

e.g.

var answer = xfa.host.messageBox("Pressing this button will reset table data. Are you sure you would like to proceed?", "Reset Form", 2, 2);

if (answer == 4){

     xfa.host.resetData();

}

You can have various answers with the messageBox depending on what kind of options you give to the user.

In the function messageBox() after "Reset Form": The first integer which is '2' is there to show the image you want to display, e.g. :

0:"X",

1:"!",

2:"?",

3:"i"

The second integer is to specify which buttons you want to display, e.g.:

1: Ok Cancel

2: Yes No

3: Yes No Cancel

4: Ok

The function messageBox() then returns an integer which results in the answer of the user, e.g.:

1 = Ok

2 = Cancel

3 = No

4 = Yes

Avatar

Former Community Member

This seems to work for bringing up the message. However, when I click the button, the message comes up but the info is already cleared. Therefore, even if I click no, the info is still cleared.

Cheers,

Wes

Avatar

Level 10

Hi Wes,

Make sure..:

1. You are in the click event

2. There is no other events in the object

3. resetData() is inside the if clause

....

If it ain't working delete the button and create a normal button and paste back the code

Avatar

Former Community Member

xfa.host.resetData(xfa.form.ONE.SAMPLE_PG_1.somExpression);

xfa.host.resetData(xfa.form.ONE.SAMPLE_PG_2.somExpression);

I had these two scripts in the click event to only clear the last 2 pages. I moved them to the if clause and now it works. Thanks for your help

Cheers,

Wes