Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do you compare two password fields, I do not want to use validators , can you do at the side behind.

Can you compare passwords while typing?
any sample codes?
Posted
Comments
WJGreyling 3-Jun-14 7:32am    
You can compare the .Text values
anoym0us 3-Jun-14 7:32am    
How do I proceed on?
WJGreyling 3-Jun-14 7:35am    
if (TextBox1.Text == TextBox2.Text)
{
//Value is true
}
else
{
//Value is false
}
anoym0us 3-Jun-14 7:36am    
Is this client or server side validation?

Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...

A very quick search gave over 8 millions hits: Google[^]

A quick look at the top hit: http://stackoverflow.com/questions/9717588/checking-password-match-while-typing[^] gives the solution...

In future, please try to do at least basic research yourself, and not waste your time or ours.
 
Share this answer
 
 
Share this answer
 
Use Jquery for that and keyup function
XML
<label>password :
    <input name="password" id="password" type="password" />
</label>
<br>
<label>confirm password:
    <input type="password" name="confirm_password" id="confirm_password" /> <span id='message'></span>


$('#confirm_password').on('keyup', function () {
    if ($(this).val() == $('#password').val()) {
        alert("paasword match");
    } 
    else 
         {
         alert("Not match");
         }
});
 
Share this answer
 
you can do it by client side and server side.. :)

client side.. :)

Javascript.. :)
JavaScript
function CheckPassword() {

          if (document.getElementById("txtPassword").value == document.getElementById("txtRePassword").value) {

              alert("password match..!!");

          }
          else {
              alert("password doesn't match..!!");
              return false;

          }
      }


HTML

ASP.NET
<asp:textbox id="txtPassword" runat="server" textmode="Password" "></asp:textbox>
       <asp:textbox id="txtRePassword" runat="server" textmode="Password" "></asp:textbox>
       <asp:button  Text="Check" id="btnCheck" runat="server" onclientclick="CheckPassword()" />



Server Side.. :)


ASP.NET
 <asp:textbox id="txtPassword" runat="server" textmode="Password" ></asp:textbox>
       <asp:textbox id="txtRePassword" runat="server" textmode="Password"></asp:textbox>
<asp:button Text="Check" id="btnCheck" runat="server" onclick="btnCheck_Click"/>


C#
public void btnCheck_Click(object sender, EventArgs e)
        {
            if (txtPassword.Text == txtRePassword.Text)
            {
                Response.Write("password Match..!!");
            }
            else
            {
                Response.Write("password doesn't Match..!!");
            
            }
        
        }
 
Share this answer
 
v3
Comments
anoym0us 3-Jun-14 8:02am    
Is this correct?
if (txtPassword.Text != txtRePassword.Text)
{
Response.Write("password Match..!!");
}
Nirav Prabtani 3-Jun-14 8:14am    
no it is wrong.. :)

you should write Response.Write("password doesn't match Match..!!");

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900