Prevent Duplicate Form Submission with jQuery Validate

To prevent users from accidentally submitting your form multiple times you can add a bit of javascript to track if the form has been submitted and prevent further submits. If you are using the jQuery Validate plugin you can do this via submitHandler.

$('form.your-form').validate({
	rules: {
		name: 'required',
		email: {
			required: true,
			email: true
		}
	},
	submitHandler: function (form) {
		// Prevent double submission
		if (!this.beenSubmitted) {
			this.beenSubmitted = true;
			form.submit();
		}
	}
});

Leave a Reply

Your email address will not be published. Required fields are marked *