0

Yet another placeholder in IE question...

I am currently using this Placeholders.js script: https://github.com/jamesallardice/Placeholders.js

Unfortunately, like all other "update the value of the input field" placeholder polyfills, it fails on password fields since the value of a password field is shown as stars. I need it to work on a password field so this is a deal-breaker.

This is for a JSP app, not a Javascript app, and the use of Javascript is minimal. I would prefer not have a JQuery dependency if I can possibly help it. Yet nearly all of the placeholder polyfills I can find are JQuery plugins.

Has anyone found a script that handles this case without JQuery? I would prefer to not write my own since there are so many edge cases.

Scott McIntyre
  • 1,365
  • 12
  • 24
  • 1
    I know you said without jQuery, but here is a good one that uses jQuery and also works for password/IE: https://github.com/danielstocks/jQuery-Placeholder/blob/master/jquery.placeholder.js – David Hellsing Dec 13 '12 at 14:37
  • Yeah, I definitely have a wealth of options if I go with JQuery, so that is plan B. This question is just one last try to find a non-JQuery solution. – Scott McIntyre Dec 13 '12 at 14:39
  • 2
    Ugh, just the thought of testing a non-jQuery solution in all legacy browsers makes me want to go home... – David Hellsing Dec 13 '12 at 14:51
  • 1
    I have now tried about 6 different JQuery ones, and this is the only one that didn't have some bugs in my use case: https://github.com/dciccale/placeholder-enhanced . Given that, I'll probably just use JQuery, since even if I find a non-JQuery one, I don't have high hopes for it being bug-free – Scott McIntyre Dec 13 '12 at 15:51
  • As a long-past follow-up, we did end up using that one I linked above. The sticking points for other ones tended to be IE7 support and lack of support for password fields. A surprising number of the polyfills show the placeholder as ********* in password fields. – Scott McIntyre Oct 03 '13 at 20:47

1 Answers1

0

You can find many examples on SO, here is one example which seems to work for many. And for all input types:

Showing Placeholder text for password field in IE

Community
  • 1
  • 1
Timmetje
  • 7,641
  • 18
  • 36
  • Aren't those all JQuery solutions? – Scott McIntyre Dec 13 '12 at 14:38
  • Well yes, but you can of course rewrite most of it to simple java script without the use of a library. But this is reinventing the wheel. You should read the rest of the link I gave though. See for example DavidJCobb answer in that thread using almost no JS at all. – Timmetje Dec 13 '12 at 14:42
  • Like you said, it's reinventing the wheel. I can do it but I would like to see if the wheel I need exists already. – Scott McIntyre Dec 13 '12 at 14:47
  • True, but in the time looking for an existing snippet which might not exist, for a browser which will be soon have discontinued support on a lot of platforms. You could have made a snippet your own. You could even copy a lot of javascript JQuery uses for the solution if you download the not minified source. Just saying: searching for snippets / code isn't always the most profitable / workable solution. In your case: passwordfield placeholder -> no jquery / ie8 / and minimal javascript. Especially the minimal javascript demand, should conclude in best to write your own snippet. – Timmetje Dec 13 '12 at 15:53