如何使Textarea像密码字段一样工作 [英] How to make a Textarea act like a password field

查看:70
本文介绍了如何使Textarea像密码字段一样工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使文本区域看起来像密码字段.在Webkit浏览器中,我找到了以下属性来实现

I am trying to make a textarea look like a password field. In webkit browsers I have found below attribute to make it

-webkit-text-security : circle    

但是在其他浏览器中不起作用.是否有任何跨浏览器替代方案...?

But it does not work in other browsers. Any cross browser alternative for this...?

推荐答案

您可以为此使用JS,定义一个变量并在其中存储textarea值,并用任何特殊字符替换textarea中的内容.您将在JS变量中获得实际值,该值可用于提交表单或验证等.

You can use JS for this, define a variable and store textarea value in that and replace contents in textarea with any special character. You 'll have actual value in JS variable which could be used to submit the form or validate etc.

为此,您可以为 keydown 事件编写函数.

For this, you can write a function for keydown event.

这篇关于如何使Textarea像密码字段一样工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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