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){
e.preventDefault();
return false;
}


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

Please,

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

Cheers

Solution

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

Solution

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

Asking just out of curiosity. :) 

Abdul quadir Saifee wrote:

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

Asking just out of curiosity. :) 

 Preventing from submit