17 lines
715 B
JavaScript
17 lines
715 B
JavaScript
document.addEventListener('DOMContentLoaded', function() {
|
|
const form = document.querySelector('form');
|
|
form.addEventListener('keydown', function(event) {
|
|
if (event.key === 'Enter') {
|
|
const activeElement = document.activeElement;
|
|
if (activeElement.tagName === 'INPUT' && activeElement.type !== 'submit') {
|
|
event.preventDefault();
|
|
const formElements = Array.from(form.elements);
|
|
const currentIndex = formElements.indexOf(activeElement);
|
|
if (currentIndex !== -1 && formElements[currentIndex + 1]) {
|
|
formElements[currentIndex + 1].focus();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|