I have a
I need a javascript method to clear the value of the textbox when the focus is
Give this in input tag of textbox:
onClick="(this.value='')"
Use the onfocus and onblur events like this:
<input type="text" name="yourName" value="A new value" onfocus="if (this.value == 'A new value') this.value = '';" onblur="if (this.value == '') this.value = 'A new value';">
Onfous And onblur Text box with javascript
<input type="text" value="A new value" onfocus="if(this.value=='A new value') this.value='';" onblur="if(this.value=='') this.value='A new value';"/>
Simple one
onfocus="javascript:this.value=''" onblur="javascript: if(this.value==''){this.value='Search...';}"
If using jQuery is acceptable:
jQuery("#myTextBox").focus( function(){
$(this).val("");
} );
just get element using
function name()
{
document.getElementById('elementid').value = "";
}
you can call this function on onfocus event of textbox and clear the value