0

I want the cursor to be in a particular textbox when the page loads. I achieved it using document.formname.formname.focus()
But the textbox has a default text. And i want it to disappear once the user starts typing. how can i get rid of this default test ?

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Jayakrishnan_gk
0

Add this code to the head of your document (Or in an external file if you use one)

<script type="text/JavaScript">
function checkValue() {
  if(document.getElementById('my_field').value == "default_value") {
    document.getElementById('my_field').value = "";
  }
}
</script>

Change my_field and default_value to the relevant values for your script.

Then add an onkeypress event to your input field for the function.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.