c# - display asterisk instead of no value in password field - Stack Overflow

I would like to display asterisk instead of no value in password field. When I am setting up the field

I would like to display asterisk instead of no value in password field. When I am setting up the field as type=text then I can see the plain text. When I set the type as password then I am getting blank field. Is there a way to display the value as asterisks?

  <input type="text" id="txtPwd" runat="server" />           

This is the field I have. Thanks in advance, Laziale

I would like to display asterisk instead of no value in password field. When I am setting up the field as type=text then I can see the plain text. When I set the type as password then I am getting blank field. Is there a way to display the value as asterisks?

  <input type="text" id="txtPwd" runat="server" />           

This is the field I have. Thanks in advance, Laziale

Share Improve this question asked Apr 30, 2013 at 21:57 LazialeLaziale 8,23548 gold badges155 silver badges271 bronze badges 4
  • Maybe it's time to update your browser, as mine shows the password fields just like expected -> FIDDLE – adeneo Commented Apr 30, 2013 at 22:00
  • Maybe I didnt get something in your question but why you cant just add a fake value to the input type="password" to display asterisk ? – RafH Commented Apr 30, 2013 at 22:00
  • Are you trying to replace the characters with asterisks as the user types them? – Dan-Nolan Commented Apr 30, 2013 at 22:02
  • Why are you not using type="password"? why reinvent the wheel? – epascarello Commented Apr 30, 2013 at 22:05
Add a ment  | 

2 Answers 2

Reset to default 4

You can use the HTML5 placeholder attribute:

 <input type="password" placeholder="●●●●●●●●●">

Example: http://jsfiddle/AJ2kn/

If you want the user's text input to be replaced by asterisks you need to use a password input—a text input just won't do it:

<input type="password" id="txtPwd" runat="server" />

However, the default value will be blank (this applies to text input as well). If you want to initialize this to a default value, you can do it like this:

<input type="password" value="dummy" id="txtPwd" runat="server" />

Note: I highly remend not putting a users' password as the default value of a password field! It may promise your users' password.

If you want to display some asterisks as placeholder text when the field is empty you can do that with with the placeholder attribute (again, this applies to text input as well):

<input type="password" placeholder="*****" id="txtPwd" runat="server" />

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744716543a4589650.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信