Reputation: 4067
I've got a textbox name txtEmpcode.When it looses focus i want to show a alert message.I've written jquery for the above functionality,but its not working...
THis is my 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");
});
});
Heres my asp.net textbox
<asp:TextBox ID="txtEmpCode" runat="server" Width="250px" ToolTip="Enter EmployeeCode"
AutoPostBack="True" ontextchanged="txtEmpCode_TextChanged"></asp:TextBox>
Upvotes: 0
Views: 1646
Reputation: 41
When a element lost the focus you could use the .blur() function in Jquery to capture the event. Example:
$(document).ready(function () {
$('#idElement').blur(function () {
alert('i lost the focus \o/');
});
});
Sorry the bad english.
Upvotes: 1
Reputation: 9931
Remove your ontextchanged="txtEmpCode_TextChanged"
from your TextBox
. Or remove your change
event from your jQuery, and implement the method for txtEmpCode_TextChanged
. Beware, the change
event for a textbox doesn't handle all cases.
Here is some good info on detecting changed text in a textbox: How to detect a textbox's content has changed
Upvotes: 0
Reputation: 2251
at the first sign you skipped %>
$("#<%=txtEmpCode.ClientID%>").change(function(){
alert("hai");
});
Upvotes: 3