最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - HTML Password Input With Prompt - Stack Overflow

programmeradmin6浏览0评论

I wish to have an input field with the prompt inside the field to save presentation space.

Is it possible to have a cross browser password input field on a form that has a text prompt such as Password: * as you start typing it either masks the password or is a true password field.

If you post the form, capture the response which is immediately stored as a password, therefore not text and as a value is submitted no prompt, but should you clear the box, the prompt Password: * re appears.

I wish to have an input field with the prompt inside the field to save presentation space.

Is it possible to have a cross browser password input field on a form that has a text prompt such as Password: * as you start typing it either masks the password or is a true password field.

If you post the form, capture the response which is immediately stored as a password, therefore not text and as a value is submitted no prompt, but should you clear the box, the prompt Password: * re appears.

Share Improve this question asked Jul 8, 2013 at 19:12 iggywebiggyweb 2,49312 gold badges51 silver badges82 bronze badges 4
  • possible duplicate of Showing Placeholder text for password field in IE – winner_joiner Commented Jul 9, 2013 at 10:42
  • In this SO-Post there are many answers and one jsfiddle example that might help here from the Answer of Kei. – winner_joiner Commented Jul 9, 2013 at 10:45
  • Just use <input type="password" placeholder="Password: *"> (together with a polyfill for IE if you need it) – Bergi Commented Jul 9, 2013 at 13:19
  • Problem Solved :You can do the trick follow this URL stackoverflow./questions/30028615/… – Mukesh Commented Jan 5, 2016 at 15:58
Add a ment  | 

3 Answers 3

Reset to default 3

HTML5 has the placeholder attribute, which you can apply to an input element, like this:

<input type="password" placeholder="Enter your password here..." />

If you need to support placeholder-like capability in pre-HTML5 browsers, then check out Cross-Browser Support For HTML5 Placeholder Text In Forms

It sounds like you are looking to watermark the input field. If you are using jQuery, you can use the watermark plugin. This particular plugin works for password marked inputs.

Or you can also use HTML 5's Placeholder as seen here on stackoverflow.

<input type="password" placeholder="password goes here" />

http://jsfiddle/qwGd6/

http://www.w3schools./tags/att_input_placeholder.asp

Note that this is not supported in IE9 and below. Go figure.

发布评论

评论列表(0)

  1. 暂无评论