forms - how to use accesskey in html -


i want form automatically switch username field password field user types in information. form automatically submit when user presses enter key.

how html?

you need javascript 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();       }      }); }); 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -