asp.net onkeyup event for textbox

前端 未结 1 1887
遥遥无期
遥遥无期 2020-12-22 08:36

I have an issue with onkeyup event with textbox. my function is to check password strength of the password textbox. so when a users enter his password, it will call the func

1条回答
  •  太阳男子
    2020-12-22 08:55

    Every control that is included in an ASP.NET Web page must contain a unique identifier (ID). To maintain this uniqueness ASP.Net change the ID of control when the page gets rendered into HTML.

    Here, if below control is inside then the ID is likely to gets changed into ctl00$ctl00$ContentPlaceHolder$tb_password for example.

    
    

    To overcome this what you can do it either use Client Mode in mark-up or use ClientID in javascript.

    Method 1:

    
    

    Method 2:

    var passwordTextbox = document.getElementById("<%=tb_password.ClientID%>");
    .
    .
    .
    .
    document.getElementById("<%=lbl_passwordStrength.ClientID%>").innerHTML = strength;
    passwordTextbox.style.color = "white";
    passwordTextbox.style.backgroundColor = backgroundColor;
    

    0 讨论(0)
提交回复
热议问题