Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Tuesday, March 20, 2018 6:20 PM
Hello,
I am designing registration form in ASP.NET using C#. In my Registration Form I have some fields and among them I have two textboxes for password & confirm-password. I am trying to match them at a time.
For example, when I type password in "password" textbox and in "confirm-password" textbox. It should compare both password at a same time without clicking on anything OR as soon I jump to next field compare both password and display message if both of them are not same.
Any Suggestion?
Thanks,
Ritul
All replies (3)
Wednesday, March 21, 2018 12:25 AM ✅Answered
Bootstrap validator
http://1000hz.github.io/bootstrap-validator/?underwear=on
Compare validator
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="TextBox1" ControlToValidate="TextBox2" ErrorMessage="not match">
</asp:CompareValidator>
Thursday, March 22, 2018 7:21 AM ✅Answered
Hi ritul29,
According to your description, I suggest you could consider using javasript to achieve your requirement.
You could use jquery keyup method to check the password.
More details, you could refer to below codes:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<script>
$(document).ready(function () {
$("#password2").keyup(validate);
});
function validate() {
var password1 = $("#password1").val();
var password2 = $("#password2").val();
if (password1 == password2) {
$("#validate-status").text("valid");
}
else {
$("#validate-status").text("invalid");
}
}
</script>
</head>
<body>
<input id="password1" type="password" />
<br />
<input id="password2" type="password" />
<p id="validate-status"></p>
</body>
</html>
Result:
Best Regards,
Brando
Tuesday, March 20, 2018 7:02 PM
Hi,
You could try https://keithscode.com/tutorials/javascript/3-a-simple-javascript-password-validator.html