HTML文本字段的行为类似于密码字段 [英] HTML text field to behave like a password field

查看:95
本文介绍了HTML文本字段的行为类似于密码字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有注册表单,我想使用密码字段。问题是,我希望它有一个占位符在开头说密码,所以我使用的是文本字段。当用户开始输入时,我需要将字符变成星号或黑色圆圈,如密码字段。

我试图通过javascript将type属性更改为password,所以我被卡住了。
有没有简单的方法来解决这个与CSS?或者没有人知道一个好的JavaScript(最好是jQuery)来破解这个?

谢谢

I have a registration form, and i want to use a password field. The problem is, i want it to have a placeholder saying "Password" at the begining so i'm using a text field instead. I need to turn the characters into asterisks or black circles like a password field when the user starts typing.
I've tried changing the "type" attribute to "password" through javascript, so i'm stuck.
Is there a simple way to resolve this with css? or does anyone know of a good javascript(preferably jquery) to hack this?
Thanks

推荐答案

悬停一个 div 或一个 span 标记在您的文本(密码)字段上,然后在密码字段获得焦点时隐藏它或点击div / span。

Hover a div or a span tag over your text (password) field, then hide it when the password field takes focus or the div/span is clicked.

这篇关于HTML文本字段的行为类似于密码字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆