Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing initial value when clicked

Status
Not open for further replies.

TonyU

Technical User
Feb 14, 2001
1,317
US
[tt] Hey all, how can I clear the values of a form field when clicked? as you can see below I have
"h:mm AM/PM" as the initial value, I've seen forms that when clicked it clears the value.

<input type=&quot;text&quot; STYLE=&quot;font-size:9pt;font-family:monospace;color:#336699&quot; name=&quot;Date&quot; size=&quot;11&quot; value=&quot;h:mm AM/PM&quot;>

Thanks
[tt]&quot;A Successful man is one who can build a firm foundation with the bricks that others throw at him&quot;[/tt]
[noevil]
 
Do it in JavaScript using the OnFocus event. If the value is h:mm AM/PM then clear it.
 
[tt]Perhaps I don't understand your suggestions but, why should I clear it when the value is h:mm AM/PM ? if the initial value is that already, I want to clear the contents of h:mm AM/PM when the user click that field.
[tt]&quot;A Successful man is one who can build a firm foundation with the bricks that others throw at him&quot;[/tt]
[noevil]
 
Because &quot;h:mm AM/PM&quot; is probably the ONLY instance where you would want to clear it. If the input box loses focus (i.e.: the user clicks on a different box, button, or element) and the user brings focus back to the box (i.e.: to correct a mistake that was made initially), the box will clear all over again. That can be quite annoying. ;)
 
[tt]Thanks for your inputdisord3r, I found a solution in the javascript forum

here it is

<input type=&quot;text&quot; STYLE=&quot;font-size:9pt;font-family:monospace;color:#336699&quot; name=&quot;Date&quot; size=&quot;11&quot; value=&quot;h:mm AM/PM&quot; onclick=&quot;javascript:this.value=''&quot;>
[tt]&quot;A Successful man is one who can build a firm foundation with the bricks that others throw at him&quot;[/tt]
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top