How to delay a form from submitting to a server

Trying to implement some javascript logic before the form is being submitted to a server. And using this javascript:

$('form').on('submit', preventSubmit);
$(':submit').on('click', preventSubmit);

function preventSubmit(e){
return false;

As a result this function is executed but it's not preventing from submitting to server.


can you check this post or this forge component or this OutSystems document, and checking if it helps you?


I found another solution using 'mousedown' event instead of click on submit button, which is called before click that submits to server

So you have added delay on mousedown and adding timeout there? or you are just preventing it from submit?

Asking just out of curiosity. :)