JavaScript使用Asp.net单击输入调用按钮提交

JavaScript使用Asp.net单击输入调用按钮提交,javascript,jquery,html,asp.net,Javascript,Jquery,Html,Asp.net,我已经创建了这个javascript <script type="text/javascript"> function handle(e) { if (e.which == 13 || e.keyCode == 13) alert("The enter was pressed"); } </script> 函数句柄(e) { if(e.which==13 | | e.keyCode==13) 警报(“按下回车键”); } 我有几个

我已经创建了这个javascript

<script type="text/javascript">
 function handle(e)
   {
    if (e.which == 13 || e.keyCode == 13)
     alert("The enter was pressed");
    }

</script>

函数句柄(e)
{
if(e.which==13 | | e.keyCode==13)
警报(“按下回车键”);
}
我有几个文本框,当我点击enter时,我会调用submit按钮

<asp:Textbox id="txtClient" Runat="Server" Width="252px"/>
<asp:Textbox id="txtDescription" Runat="Server" Width="252px"/>

<asp:Button ID="btnRegister" runat="server" Height="22px" Text="Enter" Width="100px" />

但我仍然无法显示消息框,有人能告诉我如何处理和调用按钮提交吗?


    <script type="text/javascript">
     $(document).keypress(function(e) {
         if(e.keyCode == 13) {
         alert("The enter was pressed");
        });

    </script>
$(文档)。按键(功能(e){ 如果(e.keyCode==13){ 警报(“按下回车键”); });
试试这个…

给你

$('input').on('keypress',function(e){
    if(e.which == 10 || e.which == 13) {
        alert('hit');
    }
});
更新

将其添加到文本框中并调用函数:

<asp:Textbox id="txtClient" Runat="Server" Width="252px" onkeypress="checkEnter(event)"/>

function checkEnter(ev)
{
        if(ev.which == 10 || ev.which == 13) {
        alert('hit');
    }
}

功能检查输入(ev)
{
如果(ev.which==10 | | ev.which==13){
警惕(“击中”);
}
}

很抱歉,它不起作用。我需要为文本框添加任何内容吗?并一直发送到我的主页。这让我感到很困惑,因为它也不起作用,是因为我使用asp:textbox吗?没问题..总之..编码愉快...)