Is there a way to clear the default textbox value onclick on textbox and display onblur of multiple textboxes on form page?
The divs inside the menu also have onclick() events which execute the special processing. The problem is that the onclick() events never fire when the menu is clicked, because the input field's onblur() fires first and deletes the menu, including the onclick() s!
You can use the onfocus attribute in JavaScript to clear a textbox or an input box when somebody sets focus on the field. If you are using jQuery, then use the . focus() method to clear the field.
HTML:
<input type="text" value="" onClick="Clear();" id="textbox1>
<input type="text" value="" onClick="Clear();" id="textbox2>
<input type="text" value="" onClick="Clear();" id="textbox3>
<input type="text" value="" onClick="Clear();" id="textbox4>
Javascript :
function Clear()
{
document.getElementById("textbox1").value= "";
document.getElementById("textbox2").value= "";
document.getElementById("textbox3").value= "";
document.getElementById("textbox4").value= "";
}
Your question was a little vague to me, but the above will clear all the textboxes when one is clicked. Hopefully this helps you.
One Line solution
<input type="text" value="" onClick="this.value='';" id="textbox1">
or
<input type="text" value="" onClick="this.value=='Initial Text'?this.value='':this.value;" id="textbox1">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With