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
booltrue when input receives focus. set false when loses focus. - set
booltrue when button receives focus. set false when loses focus. - subscribe click event on button, set
booltrue - subscribe keydown event of keyboard, check whether enter-key , set
booltrue.
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