Robert Nyman discusses the problem and documents his approach in his blog.
This fiddle that has all the neccessary HTML, CSS and JS.

Unfortunately, he solves the problem by changing value.
This will not work by definition if placeholder text is itself a valid input.