check password strength using JavaScript

<script>
function validate()
{
var msg;
if(document.form.strength.value.length>8)
{
msg="Strong";
}
else if(document.form.strength.value.length>3)
{
msg="Good";
}
else
{
msg="Poor";
}
document.getElementById('pw').innerHTML=msg;
}

</script>
<h1>CHECK STRENGTH OF PASSWORD</h1>
<form name="form">
<input type="password" name="strength" onkeyup="validate()">
Strength:<span id="pw">no strength</span>
</form>