-1

i'm using button key for my project but this is not work when i push Enter Key. why 'enter key' not working in this form?

<form action="" method="post">
<input type="text" >
<input type="button" >
</form>

how this is work with javascript, plz help me

i will not sue type="submit"

sia
  • 513
  • 4
  • 14

3 Answers3

2

It seems you want implicit submission:

A form element's default button is the first submit button in tree order whose form owner is that form element.

If the user agent supports letting the user submit a form implicitly (for example, on some platforms hitting the "enter" key while a text field is focused implicitly submits the form), then doing so for a form whose default button has a defined activation behavior must cause the user agent to run synthetic click activation steps on that default button.

Therefore, the button must be a submit button, not a button in button state:

<input type="submit">
Oriol
  • 274,082
  • 63
  • 437
  • 513
0

I think an <input type="submit"> is what you want :)

  • :) no i'm need use type="button" – sia Dec 30 '14 at 01:21
  • @sia, I don't know how to do that. If you need a button, a `` does the same thing, but it's not `type="button"` –  Dec 30 '14 at 01:24
0

$(form).on('submit', function{
  //do whatever you want...
})
<form action="raftel">
<input name="name" type="text"/>
<input name="password" type="password"/>
<input type="submit"/>
</form>