Skip to content

Commit bf3ebef

Browse files
committed
fix(form): able to submit when button disabled
1 parent 39e76c4 commit bf3ebef

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

js/scripts.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,17 @@ var plugin_formcreator = new function() {
13791379
return;
13801380
}
13811381
});
1382-
}
1382+
};
1383+
1384+
this.submitUserForm = function (event) {
1385+
var keyPressed = event.keyCode || event.which;
1386+
if (keyPressed === 13 && $('[name="submit_formcreator"]').is(':hidden')) {
1387+
event.preventDefault();
1388+
return false;
1389+
}
1390+
1391+
return true;
1392+
};
13831393
}
13841394

13851395
// === TARGETS ===

templates/pages/userform.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
<div class="asset">
4747
{% set formName = 'plugin_formcreator_form' %}
48-
<form name="{{ formName }}" method="post" role="form" enctype="multipart/form-data" class="plugin_formcreator_form" action={{ item.getFormURL() }} id="plugin_formcreator_form" data-itemtype="PluginFormcreatorForm" data-id="{{ item.fields['id'] }}">
48+
<form name="{{ formName }}" method="post" role="form" enctype="multipart/form-data" class="plugin_formcreator_form" action={{ item.getFormURL() }} onkeypress="return plugin_formcreator.submitUserForm(event);" id="plugin_formcreator_form" data-itemtype="PluginFormcreatorForm" data-id="{{ item.fields['id'] }}">
4949
<h1 class='form-title'>
5050
{{ __(item.fields['name'], options.domain) }}
5151
<i class="fas fa-print" style="cursor: pointer;" onclick="window.print();"></i>

0 commit comments

Comments
 (0)