why Password validation not woprking
Hi,
I am using below code..
My problem, when I enter the password and retype both less than 5 it works but when I enter 5 in the password and 4 in the retype it just proceed and gives successfully changed.
How to fix this please?
- $("#frmResetPassword").validate({
- invalidHandler: function(form, validator)
- {
- form.preventDefault();
-
- $('#txtPassword').valid();
- $('#txtRetypePassword').valid();
-
- $('#divTitle').css("background-color", "#FF0000");
- $('#msgHeader').text("Error!");
- $('#msgAlert').html("Please enter & retype your Password!<br><br>1. Must start with a capital letter.<br><br>2. Must be at least 6 digits.<br><br>3. Must have at least one number");
-
- $('#dialogAlert').popup();
- $("#dialogAlert").popup("open");
-
- return false;
- },
- rules:
- {
- txtPassword:
- {
- minlength : 5,
- required: true
- },
- txtRetypePassword:
- {
- required: true,
- minlength : 5,
- equalTo: "#txtPassword"
- }
- },
- submitHandler: function (form)
- {
- $("#btnResetPassword").parent().hide();
-
- $.mobile.loading('show', {theme:"c", text:"Please wait..", textonly: false, textVisible: true});
- $.ajax({
- method: 'POST',
- url: "change_password.php",
- // dataType: "json",
- data: $('#frmResetPassword').serialize()
- // data: $(form).serialize()
- }).done(function(data)
- {
- $.mobile.loading('hide');
-
- if (data == "true")
- {
- $('#divTitle').css("background-color", "");
- $('#msgHeader').text("Thank you");
- $('#msgAlert').html("Your Password was successfully Changed.<br><br>Please sign in using the new Password.");
- $('#dialogAlert').popup();
- $("#dialogAlert").popup("open");
-
- $("#dialogAlert").on("popupafterclose", function( event, ui )
- {
- $.mobile.loading('show', {theme:"c", text:"Please wait..", textonly: false, textVisible: true});
-
- window.location.href = "index.php?signout=true";
- });
- }
- else if (data == "false")
- {
- $('#divTitle').css("background-color", "#FF0000");
- $('#msgHeader').text("Error!");
- $('#msgAlert').html("Unable to Change your Password!");
- $('#dialogAlert').popup();
- $("#dialogAlert").popup("open");
-
- $("#dialogAlert").on("popupafterclose", function( event, ui )
- {
- $("#txtPassword").val("");
- $("#txtRetypePassword").val("");
- $("#btnResetPassword").parent().show();
- $("#txtPassword").focus();
- });
- }
- }).fail(function(jqXHR, message)
- {
- alert('Error: ' + message);
- })
- }
- });
Thanks,
Jassim