Skip to content

Commit

Permalink
Fix #14460 - Do not submit forms multiple times on CTRL + ENTER
Browse files Browse the repository at this point in the history
Fixes: #14460
Pull-request: #14968
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Apr 25, 2019
2 parents 4785192 + 2b6e7a2 commit 20f141b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/functions.js
Expand Up @@ -4890,8 +4890,11 @@ AJAX.registerOnload('functions.js', function () {
$('form input, form textarea, form select').on('keydown', function (e) {
if ((e.ctrlKey && e.which === 13) || (e.altKey && e.which === 13)) {
$form = $(this).closest('form');
if (! $form.find('input[type="submit"]') ||
! $form.find('input[type="submit"]').click()

// There could be multiple submit buttons on the same form,
// we assume all of them behave identical and just click one.
if (! $form.find('input[type="submit"]:first') ||
! $form.find('input[type="submit"]:first').trigger('click')
) {
$form.submit();
}
Expand Down

0 comments on commit 20f141b

Please sign in to comment.