Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All
How do I make it so that when a user clicks in a search text field, the
default entry (in this case "Search") is removed automatically - they
are then faced with a blank search box and can type straight away
Thanks in advance
Posted

You are talking of Textbox Watermarks. Like the one we have here in CP for Search in the Top Green bar just below the Ad at top-right corner.

It is done via using Javascript. You have few options:
1. Write your own Javasscript for the similar behavior on the fly as and when required - You would need to raise an event onfocus/onclick/onkeydown (any such event) of the textbox and clear it's value.
2. Make a custom control that has this behaviour and use it.
3. Use existing thrid party controls. For example: AJAX toolkit TextBoxWatermark Demonstration[^]

I would prefer 2 or 3.
 
Share this answer
 
Comments
Vandana87 9-Apr-11 1:22am    
plz guide me for same i am new so plz help me with the code
Sandeep Mewara 9-Apr-11 2:35am    
What else you need? See point 3 - I gave you a direct link of the control with sample and code there.

Just look at it and try out! Common...
Vandana87 9-Apr-11 7:16am    
thankx sandeep,i saw your link but i didnt got watermark option in my ajax toolkit.
i am new to this so wanted java script code for the same.thankx anyways for your guidance.
Vandana87 9-Apr-11 7:20am    
i got it thankyou.
Sandeep Mewara 9-Apr-11 7:29am    
Ok. Good to know.
Try this Link

Click[^]
 
Share this answer
 
Comments
Vandana87 9-Apr-11 1:25am    
where is test.php file,i didn't got it.if possible plz help me for the same without php file or if u can guide me javascript code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900