Expand my Community achievements bar.

Cancel saving from Presave event in case validation fails

Avatar

Level 2

I am checking some custom validation on my pdf form. If they fails then I don't want user to allow saving of form.

I tried following code on

ArrayOfDeclarationData::preSave - (JavaScript, client)

if ( !ArrayOfDeclarationData.Page1.variables.ValidateField.ValidateMandatory() && !ArrayOfDeclarationData.page2.variables.DeclValidate.ValDeclPages())

{

xfa.event.cancelAction = true;

}

but I have noticed that event is not getting cancelled and user is still able to save form. Even xfa.event.cancelAction is always false even after setting it to true.

Please help me on this issue as I have to only allow user to save user from menu / (ctrl + s) if validation passes.

Thanks

Abhi

sinhaabhinav@live.in

3 Replies

Avatar

Level 10

Hi,

It's not possible to cancel a save action, sorry.

In the documentation you might have read, that cancelAction will also work for preSave, but this is not true. It's a bug in the documentation.

Avatar

Level 2

Thanks radzmar, probably its a bug !!

Avatar

Level 10

Nope, this isn't a bug.

This behavior is because users should be able to save a form at any time and can be fill it again later.