简体   繁体   中英

form is not submitted on enter key when there is no submit button inside

is there some fix for this

<form>
<input type="text" ...

</form>

hitting the enter key inside the textfield when there is no submit button inside doesn't submit the form, is there some fix for this ?

My suggestion is.. Create a submit button. If you do not want to show the submit button, then hide the button using CSS.

You could use the keyup event of jquery and if the key pressed is 13 (enter key code) then submit the form:

$('#input-id').keyup(function(e) {
    if (e.keyCode == 13) {
        $('#form-id').submit();
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM