10-05-2012, 11:05 AM
I created a html document in which i added a predefined text in the textbox like "enter name here"
I created a function to delete the text when user clicks the input.
But , it had one problem that whenever user types his data and when he clicks the input then all his data is deleted. To prevent this used this method but this is not working , I don't know why.
here's the code
I could have done it very easily using just one function by i want to know what is wrong in this.
I don't want alternative methods of doing it, i want to know what is wrong in this?
-Himansh
I created a function to delete the text when user clicks the input.
But , it had one problem that whenever user types his data and when he clicks the input then all his data is deleted. To prevent this used this method but this is not working , I don't know why.
here's the code
Code:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function emptyfield(field){
field.value = "";
}
if(document.frmlogin.box.value != "Enter Username Here"){
frmlogin.box.onclick = "";
}
</script>
</head>
<body>
<form name="frmlogin" >
Username: <input type="text" id="cool" value="Enter Username Here" name="box" onclick="emptyfield(document.frmlogin.bo… />
</form>
</body>
</html>
I don't want alternative methods of doing it, i want to know what is wrong in this?
-Himansh
The Power to Believe in Yourself is the Power to change the Fate!