Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Textbox Input Tooltip? [duplicate]

Tags:

html

tooltip

Possible Duplicate:
How do I make an HTML text box show a hint when empty?

A very simple question. I would like to place a tooltip within a Textbox similar to the StackOverflow log in. I want the word discount on the textbox value and when the user enters a new value, the word "discount" disappears from the Textbox.

Can I do this by myself using events like OnBlur, OnChange, etc (I don't know which)? Or there is something around that is already done?

Thanks

like image 987
ivantxo Avatar asked Jan 19 '23 15:01

ivantxo


2 Answers

As said by rudeovski, you can use placeholder in modern browsers.
But for the older one, you'll need a javascript/jQuery fallback.

Here is a good example:

http://uniquemethod.com/html5-placeholder-text-with-modernizr-and-jquery-fallback

This will generate placeholder fallback for you automaticly.

You simply have to write:

<input type="text" id="discount" placeholder="discount" />

Modernizr combined with jQuery will do the rest for you.
Hope this help :)

like image 80
Simon Arnold Avatar answered Jan 21 '23 05:01

Simon Arnold


You can use placeholder text for this.

<input type="text" id="discount" placeholder="discount" />

To make it work on all browsers, you need to use jquery/javascript for it. As far as i know, it doesn't work in IE.

like image 28
mnsr Avatar answered Jan 21 '23 06:01

mnsr