title: Javascript change input type dynamically doesnt work on IE8
body: <p>i have a input field for entering password in a webpage:</p>
  
  <pre><code>&lt;input name="txtPassword" type="text" class="input2" id="txtPassword" value="Password" onfocus="txtOnFocus2('txtPassword','Password');" onblur="txtOnBlur2('txtPassword','Password');" /&gt;
  </code></pre>
  
  <p>in the initial state the usershould read "password" as the initial value and when he starts typing a password, the field should change to type password. Also when he sets it back to blank or initial value the field should change type to "text" and show password.</p>
  
  <p>I wrote code an got it working on Firefox, Chrome, and safari and its not changing the type to password on IE 8.</p>
  
  <p>this is the js code i made by editing an existing function code:</p>
  
  <pre><code> function txtOnFocus2(elementId, defaultText)
   { 
      if (document.getElementById(elementId).value == defaultText)
      {
         document.getElementById(elementId).value = "";
    document.getElementById(elementId).type = "password";
      }
   }
  
   function txtOnBlur2(elementId, defaultText)
   {
      var textValue = document.getElementById(elementId).value;
  
      if (textValue == defaultText || textValue.length == 0)
      {
        document.getElementById(elementId).type = "text"; 
    document.getElementById(elementId).value = defaultText;
      }
   }
  </code></pre>
  
  <p>This is working fine in Firefox,chrome and safari but doesn't change  field type on IE 8.</p>