4

I want to remove the confirm password validation field in my registration form. How could I do it?

3 Answers 3

4

You need to change two places

Comment password confirmation field in Magento/Customer/view/frontend/templates/form/register.phtml

    <div class="field confirmation required">
        <label for="password-confirmation" class="label"><span><?php /* @escapeNotVerified */ echo __('Confirm Password') ?></span></label>
        <div class="control">
            <input type="password" name="password_confirmation" title="<?php /* @escapeNotVerified */ echo __('Confirm Password') ?>" id="password-confirmation" class="input-text" data-validate="{required:true, equalTo:'#password'}" autocomplete="off">
        </div>
    </div>

Change the below line in Magento/Customer/Controller/Account/CreatePost.php

from

$this->checkPasswordConfirmation($password, $confirmation);

to

if(isset($confirmation))
{
    $this->checkPasswordConfirmation($password, $confirmation);
}

Info: Don't change core file directly, you must override the above files from your custom module/theme.

0
2

Go to following location and comment the below code

<div class="field confirmation required">
            <label for="password-confirmation" class="label"><span><?php /* @escapeNotVerified */ //echo __('Confirm Password') ?></span></label>
            <div class="control">
                <input type="password" name="password_confirmation" title="<?php /* @escapeNotVerified */ //echo __('Confirm Password') ?>" id="password-confirmation" class="input-text" data-validate="{required:true, equalTo:'#password'}" autocomplete="off">
            </div>
</div>

/vendor/magento/module-customer/view/frontend/templates/form/register.phtml

1

I have a similar requirement and I did the following

Overriden module-customer/view/frontend/templates/form/register.phtml in my module

Change

<input type="password" name="password_confirmation" title="<?= $block->escapeHtmlAttr(__('Confirm Password')) ?>" id="password-confirmation" class="input-text" data-validate="{required:true, equalTo:'#password'}" autocomplete="off">

to

<input type="hidden" name="password_confirmation" title="<?= $block->escapeHtmlAttr(__('Confirm Password')) ?>" id="password-confirmation" class="input-text" data-validate="{required:true, equalTo:'#password'}" autocomplete="off">

And added following in the script

$('#password').change(function() {
    $('#password-confirmation').val($(this).val());
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.