JAVASCRIPT-INNERHTML



  • The innerHTML property can be used to write the dynamic html on the html document.
  • It is used mostly in the web pages to generate the dynamic html such as registration form, comment form, links etc.

Example of innerHTML property:

To display the password strength when releases the key after press.

<script type="text/javascript" >
function validate() {
var msg;
if(document.myForm.userPass.value.length>5){
msg="good";
}
else{
msg="poor";
}
document.getElementById('mylocation').innerText=msg;
 }
 
</script>
<form name="myForm">
<input type="password" value="" name="userPass" onkeyup="validate()">
Strength:<span id="mylocation">no strength</span>
</form>


No comments:

Post a Comment