【问题标题】:Password field with numbers only仅包含数字的密码字段
【发布时间】:2015-08-04 03:39:13
【问题描述】:

我正在创建一个网络应用程序,并且我想为智能手机设置一个特殊的密码字段。 用户密码将只是数字,所以我想要一个特殊的键盘(它已经完成并且可以工作) 问题是 Firefox for android,密码字段不显示为密码,而是显示为简单的文本。

我的 ASP.NET 字段:

 <asp:TextBox Type="Number" pattern="[0-9]*" CssClass="PassTxtBox" ID="Txt_psswd" runat="server" Columns="20" MaxLength="20" Width="100%" Height="30px" ForeColor="Black"></asp:TextBox>

我的 CSS:

.PassTxtBox{
    -webkit-text-security: circle;
}

【问题讨论】:

    标签: html css asp.net firefox web


    【解决方案1】:

    将输入类型更改为Type="Password"

    <asp:TextBox Type="Password" pattern="[0-9]*" CssClass="PassTxtBox" ID="Txt_psswd" runat="server" Columns="20" MaxLength="20" Width="100%" Height="30px" ForeColor="Black"></asp:TextBox>
    

    【讨论】:

    • 不行,如果我把Type设置成密码,Android的虚拟键盘显示字母和数字。
    【解决方案2】:

    尝试将text-security:circle; 添加到PassTxtBox 类中

    .PassTxtBox{
        -webkit-text-security: circle;
        -moz-text-security:circle;
         text-security:circle;
    }
    

    尝试添加这个

     window.onload = function(){
                init(); 
            }
            function init(){
                var test= document.getElementsByTagName("input")[0];
                var style = window.getComputedStyle(x);
    
                if(style.webkitTextSecurity){
                    //Don't perform any action
                }else{
                    test.setAttribute("type","password");
                }
            }   
    

    【讨论】:

      猜你喜欢
      • 2013-04-10
      • 2020-10-23
      • 1970-01-01
      • 2017-07-05
      • 2011-11-01
      • 1970-01-01
      • 2012-05-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多