RyoSugimoto
8/21/2014 - 6:34 AM

Enter/Returnキーによるサブミットを無効化するjQueryプラグイン。

Enter/Returnキーによるサブミットを無効化するjQueryプラグイン。

;(function (window, document, $) { 
	$.fn.cancelSubmit = function() {
		return this.each(function () {
			$(this)
				.find(':text').on('keypress', function (e) {
					if (e.keyCode === 13) {
						e.preventDefault();
					}
				});
		});
	};
}(window, document, jQuery, undefined));