如何使Textarea像密码字段一样工作

编程入门 行业动态 更新时间:2024-10-09 14:24:09
本文介绍了如何使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像密码字段一样工作

本文发布于:2023-05-24 16:29:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/236213.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字段   密码   工作   Textarea

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!