Magento 1.8.1 – Fix Password Error in Checkout with New Registration Form

ce-1.8.1.0onepage-checkoutregister

I have been facing issue with Magento registration, when ever when I try to checkout with new registration, I get an password mismatch error "Please make sure your passwords match."
whereas the password entered is correct, but still I get the mismatch error, because of this, the user is unable to register itself and checkout the order,

enter image description here

The error I am getting in browser console is ,
enter image description here

Update:
By default, when I click "Register" option in checkout step, the registration form shows saved username and password of some other page in "Fax" and "Passwords" fields. So I deleted it and typed new password. Then I tried to print the values of "pass.value" and "conf.value" before the line "return (pass.value == conf.value);" in the file /js/prototype/validation.js. . But When I print the values I got "my saved password" in pass.value variable and "empty value" in conf.value variable.

How can I fix this problem ?
Any help appreciated.

Best Answer

are you absolutely sure the passwords match? turn the fields into text fields to test it.
Also take a look at how the retype password validation works.
In the file /js/prototype/validation.js there is this for password validation:

 ['validate-cpassword', 'Please make sure your passwords match.', function(v) {
            var conf = $('confirmation') ? $('confirmation') : $$('.validate-cpassword')[0];
            var pass = false;
            if ($('password')) {
                pass = $('password');
            }
            var passwordElements = $$('.validate-password');
            for (var i = 0; i < passwordElements.size(); i++) {
                var passwordElement = passwordElements[i];
                if (passwordElement.up('form').id == conf.up('form').id) {
                    pass = passwordElement;
                }
            }
            if ($$('.validate-admin-password').size()) {
                pass = $$('.validate-admin-password')[0];
            }
            return (pass.value == conf.value);
        }],

This is a good place to debug.
Maybe your markup is wrong and this fails.
try to log something before the returns statement return (pass.value == conf.value);.
See what the pass and conf fields are. Maybe you have an other password field in the page and the value for your password confirmation is matched against that one.

[EDIT]

I think I found the problem. Like I suspected there is an element with the id confirmation in your page. Everything happens because the login/register popup you have in every page. The one you get when you click the "Login/register" link in the top left corner.
There is a password confirmation field in that form with the id confirmation.
That's what it gets validated when you submit your form.
To fix this, I would take the easy way out.
I would remove the popup in the checkout page.
There are also other methods but this is the easiest. You don't need anyway the login and registration form in the checkout page because your can already do that in the checkout process.