| | |
Help on clear text in <input> !!
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved
![]() |
•
•
Join Date: Jan 2006
Posts: 14
Reputation:
Solved Threads: 0
Hi,
I need help no this web page that i'm making, I think it's a bit too simple for you guys
, so here goes nothing....
I need a text box like:
That actually clears the text when you click on it...
I tried the onClick="" tag but as I looked up it´s just for buttons, right?
Hoping somebody can help me out, yours trully: Braga_ESI
I need help no this web page that i'm making, I think it's a bit too simple for you guys
, so here goes nothing....I need a text box like:
html Syntax (Toggle Plain Text)
[HTML]<input value="Click here to clear text" name="nome" type="text"> [/HTML]
That actually clears the text when you click on it...
I tried the onClick="" tag but as I looked up it´s just for buttons, right?
Hoping somebody can help me out, yours trully: Braga_ESI
you can use "onfocus"
[HTML]<input type="text" name="name" value="Click here to clear text" onfocus="clearinputText();">[/HTML]
but this will clear the text every time when you get focus on this field,
Its a simple example only
best regards
Rahul
HTML and CSS Syntax (Toggle Plain Text)
<script language="javascript"> <!-- function clearinputText() { document.frm.name.value= ""; } //--> </script>
[HTML]<input type="text" name="name" value="Click here to clear text" onfocus="clearinputText();">[/HTML]
but this will clear the text every time when you get focus on this field,
Its a simple example only
best regards
Rahul
onClick will work on most elements, onfocus is more appropriate for a text input, as tabbing to a field also counts as focus...
try:
it will only clear the text once.. i assume you want to actually put something in the text afterwards,,
try:
HTML and CSS Syntax (Toggle Plain Text)
<input type="text" value="Click here to clear text" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;"/>
it will only clear the text once.. i assume you want to actually put something in the text afterwards,,
Plato forgot the nullahedron..
•
•
Join Date: Jan 2006
Posts: 14
Reputation:
Solved Threads: 0
•
•
•
•
onClick will work on most elements, onfocus is more appropriate for a text input, as tabbing to a field also counts as focus...
try:
HTML and CSS Syntax (Toggle Plain Text)
<input type="text" value="Click here to clear text" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;"/>
it will only clear the text once.. i assume you want to actually put something in the text afterwards,,
Thanks a lot for the help!!! My problem is solved... :lol: Sorry about my english, it's a little rustty...
•
•
Join Date: Jan 2006
Posts: 14
Reputation:
Solved Threads: 0
•
•
•
•
you can use "onfocus"
HTML and CSS Syntax (Toggle Plain Text)
<script language="javascript"> <!-- function clearinputText() { document.frm.name.value= ""; } //--> </script>
[HTML]<input type="text" name="name" value="Click here to clear text" onfocus="clearinputText();">[/HTML]
but this will clear the text every time when you get focus on this field,
Its a simple example only
best regards
Rahul
Thank you very much!!! You gave me a solution that envolves javascript
that is interesting...
ho!, and sorry about my english...
•
•
•
•
Thank you very much!!! You gave me a solution that envolves javascript that is interesting...
ho!, and sorry about my english...
HTML and CSS Syntax (Toggle Plain Text)
<script type="text/javascript"> function checkclear(what){ if(!what._haschanged){ what.value='' }; what._haschanged=true; } </code> <input type="text" value="Click here to clear text" onfocus="checkclear(this)"/>
and then use "checkclear(this)" as the onfocus property for all text inputs that you want to have the same behaviour.
Plato forgot the nullahedron..
eeek >_< i hate those buttons!
if you've just spent umpteen minutes finding information and filling out a form; would you EVER want to reset it rather than submit it?
how about this one?
EDIT: :lol:
if you've just spent umpteen minutes finding information and filling out a form; would you EVER want to reset it rather than submit it?
how about this one?
HTML and CSS Syntax (Toggle Plain Text)
<input type="reset" value="Submit!">
EDIT: :lol:
Last edited by MattEvans; Dec 10th, 2006 at 3:35 am.
Plato forgot the nullahedron..
![]() |
Similar Threads
- Text input box alignment question (HTML and CSS)
Other Threads in the HTML and CSS Forum
- Previous Thread: dynamically update pages
- Next Thread: Why arent links found?
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form google griefers hackers hitcounter hover html ie7 ie8 iframe image images internet intranet iphone javascript jpeg layout macbook maps mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization pnginie6 positioning scroll seo shopping swf swf. textcolor timecolor titletags url urlseparatedwords visualization web webdevelopment webform website windows7






