Submitting a form on 'Enter' with jQuery?

后端 未结 14 1636
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 14:45

I have a bog-standard login form - an email text field, a password field and a submit button on an AIR project that\'s using HTML/jQuery. When I hit Enter on the form, the

相关标签:
14条回答
  • 2020-11-22 15:35

    Just adding for easy implementation. You can simply make a form and then make the submit button hidden:

    For example:

    <form action="submit.php" method="post">
    Name : <input type="text" name="test">
    <input type="submit" style="display: none;">
    </form>
    
    0 讨论(0)
  • 2020-11-22 15:39

    This is my code:

      $("#txtMessage").on( "keypress", function(event) {
        if (event.which == 13 && !event.shiftKey) {
            event.preventDefault();
            $("#frSendMessage").submit();
        }
        });
    
    0 讨论(0)
提交回复
热议问题