Javascript text input fields that display instruct

2019-03-13 05:23发布

What's the best way to have a text input field that displays instructions of what to enter in that field in gray. When you focus on that input field, the gray instruction text disappears and your input text appears black. If you erase your input text and focus away from that input, then the instruction gray text reappears.

I've tried implementing this with jQuery, but I get all kinds of weird issues with different browsers. Sometimes when you go back a screen, the instruction text becomes black and no longer disappears, issues like that.

Is there a standard javascript library for this? I can't find any!

Oh, and the instruction text can't be an image because it has to be available in different languages depending on the browser's language preference.

7条回答
干净又极端
2楼-- · 2019-03-13 05:58

You can use watermark plugin in jquery.use this link.

example

 $(this).Watermark("your instructions");
查看更多
登录 后发表回答