Expand my Community achievements bar.

Preventing a user from saving until requirements are fulfilled

Avatar

Former Community Member
I am trying to prevent my users from performing a Save As on a form until all required fields are filled in. I know this will require scripting because it seems like the Save As command bypasses validation. In addition, I want to perform if-then tests to make some fields required
only if other fields are already filled in.



At the very least I want an error message to appear if the required fields are not filled in when the user attempts to save.



I tried scripting the preSave event, but a) it never seems to be executing the script, and b) even if it did, I wouldn't know how to prevent Acrobat from going through with the save.



Here's my code, whittled down to the simplest possible example:






var errorMessage;

errorMessage = "";



if(mySubform.myTextField.rawValue == "")

{

errorMessage = "Error";

}



if(errorMessage != "")

{

xfa.host.messageBox(errorMessage, "Attention", 3, 4);

}






But I'd rather the code simply abort the save entirely instead of giving a message box. Ideas? Suggestions?
0 Replies