Following problem:
On my site, I have two forms. One for login and one for main data. I have only one submit button in the mainform. The loginform is submitted via js on mainform submit.
This works fine. But in Safari I can press Enter while my focus is inside the login form. This will send the login form without the mainform, so I get an error (It redirects me to a plain view of a json I request on submit).
Is it possible to disable the "on enter pressed" action?
If you say you use anyway the JS to submit the data in the form why not cancel the default behaviour of the browser with <form onsubmit="return false;">
. This way no matter if you press the submit button or press enter in an input it won't be sent. The onsubmit="return false" shouldn't interfere with calling the submit() method on the form from JS.
You can add the onsubmit handler for your login form. This handler can help you prevent submitting your form (and for example move your cursor to the next empty field in the forms);
<form onsubmit="do_some_function(); return false;" ></form>
To prevent form from submition, return false in your onsubmit handler;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With