Cheap VPS & Xen Server


Residential Proxy Network - Hourly & Monthly Packages

JS innerText property


The innerText property can be used to write the dynamic text on the html document. Here, text will not be interpreted as html text but a normal text.

It is used mostly in the web pages to generate the dynamic content such as writing the validation message, password strength etc.

Example of innerText property

In this example, we are going to display the password strength when releases the key after press.

  1. <script type=“text/javascript” >
  2. function validate() {
  3. var msg;
  4. if(document.myForm.userPass.value.length>5){
  5. msg=“good”;
  6. }
  7. else{
  8. msg=“poor”;
  9. }
  10. document.getElementById(‘mylocation’).innerText=msg;
  11.  }
  12. </script>
  13. <form name=“myForm”>
  14. <input type=“password” value=“” name=“userPass” onkeyup=“validate()”>
  15. Strength:<span id=“mylocation”>no strength</span>
  16. </form>

Test it Now


Output of the above example

Comments

comments