Expand my Community achievements bar.

How to trigger pop-up box upon clicking "save" button to alert user that the form passed validation?

Avatar

Level 3

We have an interactive form that the user saves when completed and returns to us later. 

Currently using the script below that allows the user to save the form if it passes validation.  If they skipped a required question a pop-up appears to tell them which ones they missed.  However I would also like to have a pop-up box to appear after they click the "save" button to let them know the form was validated and can now me saved.  How do I add that?  Thanks!!

This is the script I am currently using:

if    (MICPAUMFORMtest.execValidate())

{

    app.execMenuItem("Save As") ;

}

else

{

}

10 Replies

Avatar

Level 10

You want to ask the user to confirm to save the form, is that it?

var rep = xfa.host.messageBox("Are you sure you want to save the form as it is?", "Save?", 1, 3);

if (rep == 4){     //if rep = 4 it means he answered "Yes"

     app.execMenuItem();

}

Avatar

Level 3

Now, when the user clicks the "save as" button a pop-up box only comes up if they left a required question blank causing the form to fail validation. I would like for another box to pop up when the form does not fail validation, so when the user clicks "save as" it would say something like "Your form has passed validation and is now ready to save."

Thanks!

Avatar

Level 3

Currently a box pops up when "Save as' is clicked, but it only pops up if the user skipped a required question.  It lets them know what they skipped. 

I also need a pop up to appear when the form is complete and the user clicks "Save as" that states:  the form is complete and passed all validation."

Thanks!!

Avatar

Level 10

if    (MICPAUMFORMtest.execValidate())

{

      xfa.host.messageBox("Your form has passed validation and is now ready to save.");

    app.execMenuItem("Save As") ;

}

else

{

      //MessageBox for validation failed

     xfa.host.messageBox("The form is not complete and has failed validation, please review the form.");

     //If you know which object has failed validation you can also setFocus();

     xfa.host.setFocus(this.resolveNode(PathExpression).somExpression);

     xfa.host.messageBox("Please make sure you have filled out all the fields to complete the form.");

}

Avatar

Level 3

This seems to have worked perfectly. Thank you so much! Saved me hours of time.

Hunter

Avatar

Level 3

The only thing that doesn't seem to be working is the focus setting script, but I bet it has something to do with some other setting that I have activated within the form. I'll take a look at it.

Thanks again!

Avatar

Level 10

You can't setFocus() on a hidden object...

That's one reason why setFocus() cannot work...

Maybe in your form properties -> Form Validation, you should uncheck everything to validate manually

Avatar

Level 3

One other problem I am running in to is that now when you click the "validate form" button, it does give the appropriate message when the form is not complete and it also gives the appropriate box to let the user know when the form has passed validation. However, if the form does pass validation, I need the save as box to come up once they close the "passed validation box." In other words they need to be signaled to save it once they are notified that it has passed validation. How do I fix that?

Thanks,

Hunter

Avatar

Level 3

Not sure I explained that well. The message boxes work fine now, but the "save as" function is not working when the form passes validation.

Avatar

Level 3

Ok, I found a space between Save and As. Now it seems to be working. THANKS!