javascript – How to handle the submission of a form to be executed only once?


In a Method POST form, when I click the button twice quickly it performs the submit twice.

Solutions with javascript or with the spring framework.


Disable the button after the first click, because if the request takes a long time, the user will have the perception that the request was actually sent, and will not be able to send another one.

$('form#id').submit( function( e ) {
  $( this ).children( 'input[type=submit]' ).attr( 'disabled', 'disabled' );
  return false;
<script src=""></script>
<form id="id">
  <input type="submit"/>
Scroll to Top