cancel
Showing results for 
Search instead for 
Did you mean: 
themos
Nintex Newbie

Prevent form submission from javascript

Jump to solution

Hello,

Is there a way to prevent form submission based on javascript validations?

e.g. i would like to use the following code:

NWF$(document).submit(function () {

alert('Custom validations!');

return false;

});

Instead of 'return false', I would assume there is a 'NWF.FormFiller.Functions.[?]' function to abort/prevent the form submission?

0 Kudos
Reply
3 Replies
themos
Nintex Newbie

Re: Prevent form submission from javascript

Jump to solution

After playing around with it I found the following jQuery workaround which worked for me:

event.preventDefault();

If anyone knows a better solution, please share it with the rest of us

Reply
Automation Master
Automation Master

Re: Prevent form submission from javascript

Jump to solution

Hi Themos,

nice workaround. I've done this before by writing my validate function in js (e.g. validateOnSubmit()) and then configured my submit buttons "Client click" option with:

return validateOnSubmit()

Only if the function returns true, the form will be submitted. This may be a more "standard" version but not necessarily a "better" one.

Regards

Philipp

Reply
themos
Nintex Newbie

Re: Prevent form submission from javascript

Jump to solution

Hey Philipp,

Nice solution, I hadn't thought of that!

Still, the ideal scenario would be to not even have to attach anything to specific buttons...

i.e. add the validation to the .submit() function, and prevent the submission from there!

Unfortunately, any code appended from javascript is executed AFTER the form gets posted back

so we have to attach the function to the specific button... Unless we can change the order of attached functions?!

Reply