文本框密码显示在警报消息上

时间:2013-07-08 06:49:39

标签: c# asp.net

我的文本框HTML代码是:

<asp:TextBox ID="txt_pass" 
             runat="server" class="txt-box_reg" 
             onfocus="if (this.value == 'Password') 
                     {
                        this.value = '';this.type='password';
                     }" 
             onblur="if (this.value == '') 
                     {
                        this.value = 'Password';this.type='text';
                     }" 
             value="Password"> 
</asp:TextBox>

我的javascript代码是:

<script type="text/javascript" language="javascript">
    function myFocus(element) {
        if (element.value == element.defaultValue) {
            element.value = '';
        }
    }
    function myBlur(element) {
        if (element.value == '') {
            element.value = element.defaultValue;
        }
    }
</script>

在我的页面上打开警报消息框之前,一切正常。 当警报消息打开时,密码显示,当我关闭警报框时,密码将重新获得其值...

//更多信息//

enter image description here

当我放textmode="password"然后第二个文本框显示但我用我的文本框显示为第三个文本框即。确认密码

2 个答案:

答案 0 :(得分:0)

你可以使用jQuery:

$(".txt-box_reg").focus(function (pas) {
  $(".txt-box_reg").attr("Type", "Password");
});

答案 1 :(得分:0)

做一件事,在源代码中尝试。

if(your alert box condition)
{
    //your alert box coding
    txt_pass.Text = ""; // or make text as you wish.
}
else.....

在.cs页面中执行此操作,在弹出警报框的位置。