如何删除在确认密码文本框中输入的文本框值 [英] How will i remove the text box value entered in the confirm password text box

查看:304
本文介绍了如何删除在确认密码文本框中输入的文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有两个文本框一个密码和一个确认密码文本框。输入

密码并确认密码。当删除密码文本框值并单击

提交按钮时,它也应该删除确认密码值。代码

如下所示....



Hi,
I have two text box One Password and one Confirm Password text box.After entering the
password and confirm password. When Password text box value is deleted and when
submit button is clicked then it should also delete the Confirm Password value.The code
is given below....

var valpassword= document.getElementById("Password").value;
var valconfirm= document.getElementById("Confirm").value;
if(valpassword =="")
    {
        document.getElementById("spnPassword").innerHTML = "Please enter your Password";
    }
    if(valconfirm =="")
    {
        document.getElementById("spnConfirm").innerHTML = "Please confirm your Password";
    }
    else if(valpassword!=valconfirm)
    {
        document.getElementById("spnConfirm").innerHTML = "Your passwords do not match ";
    }
    else if(document.getElementById("Password").value=="" &&  document.getElementById("Confirm").value!="")
    {
        document.getElementById("Confirm").value="";
    }
    return true;

推荐答案

这样的事情:



Something like this:

function deleteConfirmPasswordText()
{
    if(document.getElementById("txtPassword").value == "") {
        document.getElementById("txtConfirmPassword").value = "";
    }
    return false;
}







<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
<asp:TextBox ID="txtConfirmPassword" runat="server" TextMode="Password"></asp:TextBox>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="return deleteConfirmPasswordText();" />





注意:return false是因为如果密码文本框为空,表单不应发布。你必须在客户端和服务器端都有这些验证。



希望这有帮助!



Note: return false is because the form shouldn't post if the password text box is empty. You must have these validations in place, both at client side and server side.

Hope this helps!


你需要将文本框文本属性设置为null或。
You need to set the textbox text property to null or "".


这篇关于如何删除在确认密码文本框中输入的文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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