title: asp.net onkeyup event for textbox
body: <p>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 function of checking password strength and show in a label if his password is very weak/weak/medium/strong. Also, the textbox background will show colors according to the strength of the password. however when i type in the password textbox, the label does not show anything and the textbox does not change color.</p>
  
  <pre><code>&lt;asp:TextBox ID="tb_password" runat="server" TextMode="Password" onKeyUp="checkPasswordStrength()"  &gt;&lt;/asp:TextBox&gt;
                          &lt;script type="text/javascript"&gt;
      function checkPasswordStrength()
      {
          var passwordTextbox = document.getElementById("tb_password");
          var password = passwordTextbox.value;
          var specialCharacters = "!@#$%^&amp;*_+";
          var passwordScore = 0;
  
          for (var i = 0; i &lt; password.length; i++)
          {
              if(specialCharacters.indexOf(password.charAt(i) &gt; -1))
              {
                  passwordScore += 20;
              }
          }
  
          if (/[a-z]/.test(password))
          {
              passwordScore += 20;
          }
  
          if (/[A-Z]/.test(password)) {
              passwordScore += 20;
          }
  
          if (password.length &gt;= 8) {
              passwordScore += 20;
          }
  
          if (/[\d]/.test(password)) {
              passwordScore += 20;
          }
  
          var strength = "";
          var backgroundColor = "";
  
          if (passwordScore &gt;= 100)
          {
              strength = "Strong"
              backgroundColor = "green";
          }
  
          else if (passwordScore &gt;= 80)
          {
              strength = "Medium"
              backgroundColor = "yellow";
          }
  
          else if (passwordScore &gt;= 60) {
              strength = "Weak"
              backgroundColor = "red";
          }
  
          else
          {
              strength = "Very Weak"
              backgroundColor = "maroon";
          }
  
          document.getElementById("lbl_passwordStrength").innerHTML = strength;
          passwordTextbox.style.color = "white";
          passwordTextbox.style.backgroundColor = backgroundColor;
      }
  
  &lt;/script&gt;
                          &lt;br /&gt;
                          &lt;asp:Label ID="lbl_passwordStrength" runat="server"&gt;&lt;/asp:Label&gt;
  </code></pre>