Perform Click on Submit

Perform Click on Submit

Hi,

I have below code. I am using a button to sign in but now I want to perform the button click when the user submit the form by pressing enter on the txtLoginName or txtPassword.

How can I do this please?


  1. $('#btnSubmit').click(function ()
  2. {
  3. $("#wrapper").hide();
  4. $("#gradient").hide();
  5. $("#wait").show();

  6. $.ajax({
  7. type: 'POST',
  8. url: "login_user.php",
  9. data: $('#login-form').serialize(),
  10. success: function()
  11. {
  12. window.location.href = 'my.php';
  13. },
  14. error: function(jq,status,message)
  15. {
  16. alert('A jQuery error has occurred. Status: ' + status + ' - Message: ' + message);
  17. }

  18. });
  19. });