ankush
02-03-2012, 01:21 PM
<html>
<head>
<title>txtbox</title>
<script type="text/javascript">
function blank(a)
{
if(a.value == a.defaultValue) a.value = "";
}
function fill(a)
{
if(a.value == "") a.value = a.defaultValue;
}
</script>
</head>
<body>
<form name="em" action="#" method="post">
<input type="text" value="Enter your email" onfocus="blank(this)" onblur="fill(this)" />
</form>
</body>
</html>
i want to blank textbox on focus and then again fill the default value on blur, this code is working fine but that default text in the textbox is of same color which when we write something in the textbox, i want the default text should be of different color like #CCC and when we insert text it should be of #000 color, i tried define the text color of textbox but then both text color are showing same, any help
<head>
<title>txtbox</title>
<script type="text/javascript">
function blank(a)
{
if(a.value == a.defaultValue) a.value = "";
}
function fill(a)
{
if(a.value == "") a.value = a.defaultValue;
}
</script>
</head>
<body>
<form name="em" action="#" method="post">
<input type="text" value="Enter your email" onfocus="blank(this)" onblur="fill(this)" />
</form>
</body>
</html>
i want to blank textbox on focus and then again fill the default value on blur, this code is working fine but that default text in the textbox is of same color which when we write something in the textbox, i want the default text should be of different color like #CCC and when we insert text it should be of #000 color, i tried define the text color of textbox but then both text color are showing same, any help