focus problem in mozilla
In my application I am using a text box with onBlur property assigned to a function i cant focus by telling the id in Mozilla the code is as follows
<asp:TextBox ID="txtPassword" AutoCompleteType="Disabled" autocomplete="off" runat="server" MaxLength="25" Width="350px" TextMode="Password" onBlur="return ValidatePassword(this.text);"> </asp:TextBox>
Javascript function
开发者_C百科function ValidatePassword(element)
{
element.focus();
}
onblur
is a client side function, to get the value of the textbox in client side, use .value
not .text
.
onBlur="return ValidatePassword(this);"
function ValidatePassword(element) {
if(element.value.length < 5){
setTimeout(function(){
element.focus();
}, 100);
}
}
Try changing it to:
<asp:TextBox ID="txtPassword" AutoCompleteType="Disabled"
autocomplete="off" runat="server"
MaxLength="25" Width="350px" TextMode="Password" onBlur="return
ValidatePassword(document.getelementById('<%=txtPassword.ClientID%>'));">
</asp:TextBox>
精彩评论