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();
		}
	}
});
0 0 vote
Article Rating
in JavaScript, jQuery
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Joel Lindsey
Joel Lindsey
2 months ago

Thanks, this was exactly what I needed to fix my issue!