javascript - form submit trigger in html -
in html, form can submitted
- clicking submit button
- pressing enter when focus on submit button
- by pressing enter on input field
is there way find out of 3 methods used submit form?
html doesn't have built-in way of knowing, far know. you'd have catch necessary events , keep state in memory. following:
- set
bool
true when input receives focus. set false when loses focus. - set
bool
true when button receives focus. set false when loses focus. - subscribe click event on button, set
bool
true - subscribe keydown event of keyboard, check whether enter-key , set
bool
true.
now should have necessary information know actions user took submit form. jquery should able these events.
also, believe form submitted when form has focus (so not button or input) , press enter. i'm not sure if actual form having focus, or control inside form.
so, you're trying achieve require hacking around. sure can't provide users experience want in other way?
Comments
Post a Comment