Hi, when i’m typing in a form text field i want to be able to hit the “enter” button without sending the form. I’ve created a short example: https://crazy-form-submission.webflow.io/. Also it would be great to design the text field, so that you can start typing at the top, not the middle.
This piece of code will make is so that the forms goes to the next field instead of submitting:
<script>
$(document).ready(function() {
$('form input').keydown(function(event) {
if (event.keyCode === 13) { // Enter key
event.preventDefault(); // Prevent form submission
// Get the current input index
var currentIndex = $('form input').index(this);
// Focus on the next input field
$('form input').eq(currentIndex + 1).focus();
}
});
});
</script>
Be aware that I haven’t selected any class specifically with jQuery, so you might want to narrow that down in the future.