[英]JavaScript click enter call button submit using Asp.net
I have created this javascript. 我已经创建了这个javascript。
<script type="text/javascript">
function handle(e)
{
if (e.which == 13 || e.keyCode == 13)
alert("The enter was pressed");
}
</script>
And I have few text box, which I expected when I click enter, I will call button submit. 而且我只有几个文本框,我希望在单击Enter时将其称为按钮提交。
<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" />
But I still cannot display the message box, can someone show me how to handle and call button submit? 但是我仍然无法显示消息框,有人可以告诉我如何处理和调用按钮提交吗?
<script type="text/javascript">
$(document).keypress(function(e) {
if(e.keyCode == 13) {
alert("The enter was pressed");
});
</script>
try this... 尝试这个...
Here you go 干得好
$('input').on('keypress',function(e){
if(e.which == 10 || e.which == 13) {
alert('hit');
}
});
UPDATE 更新
Add this in your text box and call a function: 在您的文本框中添加它并调用一个函数:
<asp:Textbox id="txtClient" Runat="Server" Width="252px" onkeypress="checkEnter(event)"/>
function checkEnter(ev)
{
if(ev.which == 10 || ev.which == 13) {
alert('hit');
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.