![](/img/trans.png)
[英]unable to call Javascript after asp.net submit button click event handler is completed
[英]JavaScript click enter call button submit using Asp.net
我已经创建了这个javascript。
<script type="text/javascript">
function handle(e)
{
if (e.which == 13 || e.keyCode == 13)
alert("The enter was pressed");
}
</script>
而且我只有几个文本框,我希望在单击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" />
但是我仍然无法显示消息框,有人可以告诉我如何处理和调用按钮提交吗?
<script type="text/javascript">
$(document).keypress(function(e) {
if(e.keyCode == 13) {
alert("The enter was pressed");
});
</script>
尝试这个...
干得好
$('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');
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.