Forum guidelines
AuthorQuestion
Confirm password validation in javascript?
Posted on: 15 May 2012
hi ...


 below code is my pwd and confirm pwd required filed validation in javascript..

now i want to chk this pwd and confirm pwd should same using javascript code...

help me to give confirm password validation in javascript.


if (document.getElementById("<%=txtpwd.ClientID %>").value == "") {
  alert("(*)Enter the password");
  document.getElementById("<%=txtpwd.ClientID %>").focus();
  return false;
  }

  if (document.getElementById("<%=txtConfirmPwd.ClientID %>").value == "") {
  alert("(*)Enter the Confirm Password");
  document.getElementById("<%=txtConfirmPwd.ClientID %>").focus();
  return false;
  }

Advanx THx


If the Answer is Helpful to you, then mark it as correct answer..!


Sudharsan S
AuthorReply
Re: confirm password validation in javascript?
Posted on: 15 May 2012  
try this

string _pwd=document.getElementById("<%=txtpwd.ClientId%>").Value;
string _confirm=document.getElementById("<%=txtconfirm.ClientId%>").Value;
if(_pwd==_confirm)
{
//success
}
else
{
//Error
}

Mark as "This Is Correct Answer" if helps you.
Re: confirm password validation in javascript?
Posted on: 15 May 2012  
You need to Check the Passwords like this
 function IsBlankOrNot() {
                if ($('#txtbx1').val() != null || $('#txtbx1').val() != String.empty()) {
                    alert($(this)[0].id + "can't leave blank");
                }
                else if ($('#txtbx2').val() != null || $('#txtbx2').val() != String.empty()) {
                    alert($(this)[0].id + "can't leave blank");
                }
            }
            $('input[value="Validate"]').click(function () {
                IsBlankOrNot();
            });
            $('#txtbx2').blur(function () {
                var firstTextBox = $('#txtbx1').val();
                var secondTextBox = $('#txtbx2').val();
                if (firstTextBox.toLowerCase() == secondTextBox.toLowerCase()) {
                    alert('Both the Textboxes are same');
                }
                else {
                    alert('Both the Textboxes are not same');
                }
            });

Mark as "Accepted Answer" if it helps you .


Re: confirm password validation in javascript?
Posted on: 15 May 2012  
thx fro ur reply krishna.. But still it is not working

If the Answer is Helpful to you, then mark it as correct answer..!


Sudharsan S
Re: confirm password validation in javascript?
Posted on: 15 May 2012  
thx for ur reply hemant.. But still it is not working

If the Answer is Helpful to you, then mark it as correct answer..!


Sudharsan S

SPONSORED BY

Offshore Software and Database Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.