Losing focus in jquery Event We only need to use blur to bind, so that we can monitor the blur action of the input box in real time.
A supervisor text event
1 2 3 4 5 6 7 8 9 | $( function () {
$(':text').blur( function () {
if ($.trim($(this).val())=='') {
$(this).css('border', 'red');
} else {
$(this).css('border','white');
}
});
});
|
Copy after login
Instance
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <script src= "Scripts/jquery-1.4.1.js" type= "text/javascript" ></script>
<script language= "javascript" type= "text/javascript" >
function OnFousFun(element1, element2, text) {
if ($(element1).val() == "" || $(element1).val() == text) {
$(element2).html( "输入不能为空" );
return false;
}
else {
$(element2).html( "" );
return true;
}
}
</script>
|
Copy after login
Page code
1 2 3 4 5 6 7 8 9 10 | <tr>
<th>
校长证件号码</th>
<td>
<asp:TextBox ID= "txtCardID" runat= "server" CssClass= "formbox" TabIndex= "1" MaxLength= "50"
Text='15位或18位' onblur= "OnFousFun('#ContentPlaceHolder1_txtCardID','#ContentPlaceHolder1_Label1','15位或18位')" >
</asp:TextBox>
<asp:Label ID= "Label1" runat= "server" ForeColor= "Red" ></asp:Label>
</td>
</tr>
|
Copy after login
Description: onblur is an event when the text box loses focus
The above is the detailed content of jquery lost focus event blur sample code sharing. For more information, please follow other related articles on the PHP Chinese website!