tags:

views:

34

answers:

3

i want a feature then when user fill username and goes for fill the password then if he click ENTER then form is automatically submit how i can do this in html

+1  A: 

http://www.htmlcodetutorial.com/forms/index_famsupp_157.html

this probably would help ;)

Saikios
+3  A: 

You need javascript for that:

var el = document.getElementById('field_id');

el.onkeypress = function(event){
  var key = event.keycode || event.which;

  if (key === 13) {
     document.FormName.submit();
  }
};

jQuery: (based on comment)

$(function(){
    $('#form_id:input').keypress(function(event){
      var key = event.keycode || event.which;

      if (key === 13) {
         $(this).parents('form').submit();
      }

    });
});
Sarfraz
@ sarfaraz are you convert it to jquery
steven spielberg
@steven spielberg: See my updated answer please.
Sarfraz
+1  A: 

Example-

<FORM action="..." method="post">
<P>
<LABEL for="fuser" accesskey="U">
User Name
</LABEL>
<INPUT type="text" name="user" id="fuser">
</P>
</FORM>

See details HERE