I am creating a form using codeigniter, I wanted to know whether there is a way that we can create atext field having a default text and as soon as user clicks on that field the default text disappears. I was wondering whether there is any method in codeigniter that allows us to do this?
Thanks
Any efforts will be appreciated
Important Note: This solution was posted many years ago and is no longer applicable. Please see the edits below for an alternative solution using HTML5.
You need jQuery for DOM functionalities. The cool thing about jQuery is that many of the functionalities we see everyday on Web 2.0 sites already have their jQuery plugin counterparts. BTW, Codeigniter is a PHP framework while jQuery is javascript framework so you won’t be needing Codeigniter for this specific feature.
What you need is an in-label plugin for jQuery. This is the best I’ve tried so far: http://fuelyourcoding.com/scripts/infield/
As for the code this is basically the only thing you need:
Instead of removing the text outright, it fades the inline label slowly or until you type in something. Check it out.
To date, the solution above is no longer necessary. using HTML5, users can use the following HTML codes: