Merge pull request #2525 from jaschaurbach/fix-form-submit

Update forms.js
This commit is contained in:
Mouse Reeve 2022-12-21 11:10:21 -08:00 committed by GitHub
commit 6947e74f5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -46,4 +46,16 @@
document
.querySelectorAll("[data-remove]")
.forEach((node) => node.addEventListener("click", removeInput));
// Get the element, add a keypress listener...
document.getElementById("subjects").addEventListener("keypress", function (e) {
// e.target is the element where it listens!
// if e.target is input field within the "subjects" div, do stuff
if (e.target && e.target.nodeName == "INPUT") {
// Item found, prevent default
if (event.keyCode == 13) {
event.preventDefault();
}
}
});
})();

View file

@ -81,7 +81,7 @@
{% include 'snippets/form_errors.html' with errors_list=form.languages.errors id="desc_languages" %}
</div>
<div class="field">
<div class="field" id="subjects">
<label class="label" for="id_add_subjects">
{% trans "Subjects:" %}
</label>