需要在asp .net文本框中使用Focus [英] Need to use Focus in asp .net text box
本文介绍了需要在asp .net文本框中使用Focus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在blur()事件中我使用jquery进行验证。如果发生验证,文本框颜色应该更改,并且光标应该在同一文本框中。我已经使用了focus(),但它没有用。你可以帮我这个吗?
in on blur() event i have used jquery for validation . If validation occurs the text box color should change and the cursor should be on the same text box . I have used focus() for this , but it is not working. Can you help me on this ?
<asp:TextBox ID="txtMemoName" runat="server" Width="200px" onblur="alertevent();" ></asp:TextBox>
function alertevent() {
var value = $("#<%=txtMemoName.ClientID %>").val();
if (value == "") {
$("#<%=txtMemoName.ClientID %>").focus();
$("#<%=txtMemoName.ClientID %>").css('border', '1px solid red');
}
}
推荐答案
( #<%= txtMemoName.ClientID%>)。val();
if (value == ){
("#<%=txtMemoName.ClientID %>").val(); if (value == "") {
( #<%= txtMemoName.ClientID %>)。focus();
("#<%=txtMemoName.ClientID %>").focus();
( #<%= txtMemoName.ClientID%>)。css(' border',' 1px solid red');
}
}
("#<%=txtMemoName.ClientID %>").css('border', '1px solid red'); } }
这篇关于需要在asp .net文本框中使用Focus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文