Return to Snippet

Revision: 26810
at May 11, 2010 13:54 by shibbard


Initial Code
$('#textBoxId').keydown(function(e) {
  if(e.keyCode === 13) {
    e.preventDefault(); 
    $('#buttonId').trigger('click');
  }
});

or - not tested:

$('#textBoxId').keydown(function(event) {
    var e = event || window.event;
    var keyCode = document.all ? e.keyCode : e.which;

    if (keyCode == 13) {
        e.preventDefault();
        $('#buttonId')[0].click();
    }
});

Initial URL
http://stackoverflow.com/questions/494076/jquery-and-asp-net-forcing-button-click

Initial Description

                                

Initial Title
ASP.Net Trigger button with Enter

Initial Tags

                                

Initial Language
JavaScript