![](/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.