我想用密码文本框添加显示和隐藏功能 [英] I want to add show and hide functionality with password textbox

查看:119
本文介绍了我想用密码文本框添加显示和隐藏功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现文本框密码的显示和隐藏功能,我已经在jquerr的帮助下完成了它,当我第一次点击显示密码但当我点击第二次显示密码复选框时,它正常工作,自动化显示密码复选框消失,请帮助我解决这个问题



我尝试过:



I want to implement show and hide functionality for textbox Password,I have done that with the help of jquerr it is working properly when i click on show password first time but when i am clicking second time on show password checkbox,autometically the show password checkbox goes disappear,please help me with this problem

What I have tried:

<div class="form-group">
                          <asp:Label ID="lblPassword" runat="server" Text="Password" Font-Bold="true"></asp:Label>
                            <asp:TextBox ID="txtPassword" runat="server"  TextMode="Password" CssClass="form-control" placeholder="Enter Password Here" ></asp:TextBox>
                           <label for="chkShowPassword">
                             <input type="checkbox" id="chkShowPassword" />
                                      Show password</label>







<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>







$(function(){

调试器;

$(#chkShowPassword)。bind(click,function(){

var txtPassword = $([id * = txtPassword]] );

if($(this).is(:checked)){

txtPassword.after('< input onchange =PasswordChanged(this) ;id =txt_'+ txtPassword.attr(id)+'type =textvalue ='+ txtPassword.v al()+'/>');

txtPassword.hide();

} else {

txtPassword.val(txtPassword .next()。val());

txtPassword.next()。remove();

txtPassword.show();

}

});

});



函数PasswordChanged(txt){

$(txt).prev()。val($(txt).val());

}




$(function () {
debugger;
$("#chkShowPassword").bind("click", function () {
var txtPassword = $("[id*=txtPassword]");
if ($(this).is(":checked")) {
txtPassword.after('<input onchange = "PasswordChanged(this);" id = "txt_' + txtPassword.attr("id") + '" type = "text" value = "' + txtPassword.val() + '" />');
txtPassword.hide();
} else {
txtPassword.val(txtPassword.next().val());
txtPassword.next().remove();
txtPassword.show();
}
});
});

function PasswordChanged(txt) {
$(txt).prev().val($(txt).val());
}

推荐答案

(function(){

debugger;
(function () {
debugger;


(#chkShowPassword)。bind(click,function(){

var txtPassword =
("#chkShowPassword").bind("click", function () {
var txtPassword =


([id * = txtPassword]);

if(
("[id*=txtPassword]");
if (


这篇关于我想用密码文本框添加显示和隐藏功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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