Why are some forms automatically submitted when I press the enter button, while others are not?

Problem:

I never specify a submit button, since I use ajax to submit my forms, but some forms have an automatic submit function independently.

Background:

In my application, I have instances where pressing the enter button automatically submits the form and other instances where it will do nothing. For example; There are times when I will need to grab the enter button to receive automatic sending, but at other times when it seems that this just happens on it, and I did not find the template. Except that dynamically created forms seem to have auto-update functionality, but static ones don't? Someone else has a similar problem.

Example:

In all my forms, the submit button has been removed, and I do not specify any target elements or action elements, as shown below. All forms are submitted via AJAX.

<form id="ajaxForm"> <input> </form> <button>ButtonOutSideForm</button> 

Do not look for a way to prevent automatic sending

I already know about "onsubmit = return false" and e.preventDefault. I'm not looking for a way to disable auto-send. My question is why this presence seems arbitrary. Thanks.

+7
source share
1 answer

As pointed out by LouD. Some browsers will automatically submit if the form contains only one input element. Why forms with one input field are sent when you press the enter key on the input

+4
source

All Articles