JavaScript Program of KeyUp to Increase Width With Validation
<!doctype html>
<html>
<head>
<meta charset=”utf-8″>
<title>Untitled Document</title>
<style>
#s1{width:0px;
height:50px;
background-color:red;
}
</style>
</head>
<body>
<input type=”text” id=”ss” onKeyUp=”sanjay()”>
<div id=”s1″></div>
<script>
a=0;
function sanjay()
{
gg=document.getElementById(“ss”).value;
bb=gg.length;
a=bb*20;
aa=document.getElementById(“s1″);
aa.style.width=a+”px”;
if(bb>=8)
{
aa.style.backgroundColor=”green”;
}
else
{
aa.style.backgroundColor=”red”;
}
}
</script>
</body>
</html>