简体   繁体   中英

HTML Password Input With Prompt

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.

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

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

http://jsfiddle.net/qwGd6/

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

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM