0

テキストボックス名 txtEmpcode があります。フォーカスを失ったときに警告メッセージを表示したいです。上記の機能のために jquery を作成しましたが、機能しません...

これは私のjqueryです

$(document).ready(function(){
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    //Raised before processing of an asynchronous postback starts and the postback request is sent to the server.
    prm.add_beginRequest(BeginRequestHandler);
    // Raised after an asynchronous postback is finished and control has been returned to the browser.
    prm.add_endRequest(EndRequestHandler);    
    AutoComp();//Function for autocomplete textbox        

    $("#<%=txtEmpCode.ClientID").change(function(){         
        alert("hai");
    });

});

ここに私のasp.netテキストボックスがあります

<asp:TextBox ID="txtEmpCode" runat="server" Width="250px" ToolTip="Enter EmployeeCode" 
AutoPostBack="True"  ontextchanged="txtEmpCode_TextChanged"></asp:TextBox>
4

3 に答える 3

3

スキップした最初の標識で %>

$("#<%=txtEmpCode.ClientID%>").change(function(){         
        alert("hai");
    });
于 2012-09-27T17:11:44.600 に答える
1

要素がフォーカスを失った場合、Jquery で .blur() 関数を使用してイベントをキャプチャできます。例:

 $(document).ready(function () {
        $('#idElement').blur(function () {
           alert('i lost the focus \o/');
        });

});

悪い英語でごめんなさい。

于 2013-03-04T13:00:53.920 に答える
0

から を削除ontextchanged="txtEmpCode_TextChanged"しますTextBox。またはchange、jQuery からイベントを削除し、のメソッドを実装しますtxtEmpCode_TextChangedchangeテキストボックスのイベントがすべてのケースを処理するわけではないことに注意してください。

テキストボックス内の変更されたテキストを検出するための良い情報を次に示します:テキストボックスの内容が変更されたことを検出する方法

于 2012-09-27T17:12:35.863 に答える