Skip to main content

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?

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 happy.png


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


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 sad.png

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


Reply