From fa1d1e5ac7a101068016296c00baa55a420f7d40 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 24 Nov 2016 10:42:18 +0800 Subject: webui: main.js: Prevent form submitting on "Enter" press --- fg21sim/webui/static/js/main.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'fg21sim/webui/static/js') diff --git a/fg21sim/webui/static/js/main.js b/fg21sim/webui/static/js/main.js index dc471dc..f0755c2 100644 --- a/fg21sim/webui/static/js/main.js +++ b/fg21sim/webui/static/js/main.js @@ -249,4 +249,13 @@ $(document).ready(function () { var body = toggle.closest(".panel").find(".panel-body"); toggleBlock(toggle, body); }); + + // Prevent from submitting form by "Enter" + // Credit; https://stackoverflow.com/a/11235672/4856091 + $("form").on("keypress", function (e) { + if (e.which === 13) { + e.preventDefault(); + return false; + } + }); }); -- cgit v1.2.2