How to prevent multiple form submission in jQuery?


Source Code:

<script>
	$(document).ready(function() {
		$("form").submit(function( event ) {
			if(typeof jQuery.data(this, "disabledOnSubmit") == "undefined") {
				jQuery.data(this, "disabledOnSubmit", { submited: true });
				$("input[type=submit], input[type=button]", this).each(function() {
					$(this).attr("disabled", "disabled");
				});
			}
			else {
				event.preventDefault();
			}
		});
	});
</script>

Buy us coffee

Reviews and Comments