Jump to content

[SOLVED] how to add Password Confirm field


fatheeym

Recommended Posts

first i have searched for the solution but non of theme worked with me

i've delteted the password from welcome e-mail template

so i have to add field in registration for Password Confirmation

to avoid users type the password wrong

---------

i'm using the last version of prestashop and the deafault theme

thank you

Edited by fatheeym (see edit history)
Link to comment
Share on other sites

Find the following code in themes/default-bootstrap/authentication.tpl at about line 492:

            <div class="required password form-group">
                <label for="passwd">{l s='Password'} <sup>*</sup></label>
                <input type="password" class="is_required validate form-control" data-validate="isPasswd" name="passwd" id="passwd" />
                <span class="form_info">{l s='(Five characters minimum)'}</span>
            </div>

and then change it to:

            <div class="required password form-group">
                <label for="passwd">{l s='Password'} <sup>*</sup></label>
                <input type="password" class="is_required validate form-control" data-validate="isPasswd" name="passwd" id="passwd" />
                <span class="form_info">{l s='(Five characters minimum)'}</span>
            </div>
            <div class="required password form-group">
                <label for="passwd">{l s='Confirmation'} <sup>*</sup></label>
                <input type="password" class="is_required validate form-control" data-validate="isPasswd" name="confirm" id="confirm_passwd" onblur="if ($(this).val() == $('#passwd').val()) $(this).parent().attr('class', 'required password form-group form-ok'); else $(this).parent().attr('class', 'required password form-group form-error');" />
            </div>

This will add a new "Confirmation" field that will turn red if the customer leaves the field and the value it doesn't match the "Password" field. If the passwords match, it will turn green.

 

You'll also need to create override/controllers/front/AuthController.php with the following to prevent an account being created when the passwords don't match:

<?php

class AuthController extends AuthControllerCore
{
    protected function processSubmitAccount()
    {
        if (Tools::getValue('passwd') != Tools::getValue('confirm')) {
            $this->errors[] = Tools::displayError('Password and confirmation do not match');
        }

        parent::processSubmitAccount();            
    }
}

This will display a "Password and confirmation do not match" error message if a customer clicks the "Register" button when the passwords don't match. Remember to go to Advanced Parameters > Performance and click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override.

Edited by rocky
Fixed authentication.tpl code (see edit history)
  • Like 3
Link to comment
Share on other sites

  • 1 year later...
On 25/7/2016 at 6:12 PM, rocky said:

Find the following code in themes/default-bootstrap/authentication.tpl at about line 492:


            <div class="required password form-group">
                <label for="passwd">{l s='Password'} <sup>*</sup></label>
                <input type="password" class="is_required validate form-control" data-validate="isPasswd" name="passwd" id="passwd" />
                <span class="form_info">{l s='(Five characters minimum)'}</span>
            </div>

and then change it to:


            <div class="required password form-group">
                <label for="passwd">{l s='Password'} <sup>*</sup></label>
                <input type="password" class="is_required validate form-control" data-validate="isPasswd" name="passwd" id="passwd" />
                <span class="form_info">{l s='(Five characters minimum)'}</span>
            </div>
            <div class="required password form-group">
                <label for="passwd">{l s='Confirmation'} <sup>*</sup></label>
                <input type="password" class="is_required validate form-control" data-validate="isPasswd" name="confirm" id="confirm_passwd" onblur="if ($(this).val() == $('#passwd').val()) $(this).parent().attr('class', 'required password form-group form-ok'); else $(this).parent().attr('class', 'required password form-group form-error');" />
            </div>

This will add a new "Confirmation" field that will turn red if the customer leaves the field and the value it doesn't match the "Password" field. If the passwords match, it will turn green.

 

You'll also need to create override/controllers/front/AuthController.php with the following to prevent an account being created when the passwords don't match:


<?php

class AuthController extends AuthControllerCore
{
    protected function processSubmitAccount()
    {
        if (Tools::getValue('passwd') != Tools::getValue('confirm')) {
            $this->errors[] = Tools::displayError('Password and confirmation do not match');
        }

        parent::processSubmitAccount();            
    }
}

This will display a "Password and confirmation do not match" error message if a customer clicks the "Register" button when the passwords don't match. Remember to go to Advanced Parameters > Performance and click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override.

Hi, i just did this in prestashop 1.6.1.18 and works great, how can i do the same thing but with the email field? What i should change and where? 

Thank you very much

Link to comment
Share on other sites

  • 10 months later...
  • 2 months later...
On 7/26/2016 at 3:12 AM, rocky said:

protected function processSubmitAccount() { if (Tools::getValue('passwd') != Tools::getValue('confirm')) { $this->errors[] = Tools::displayError('Password and confirmation do not match'); } parent::processSubmitAccount(); }

hello thanks I got the codes I get the white page error when everything makes it mandatory alone only there is error in the codes

Link to comment
Share on other sites

On 7/26/2016 at 3:12 AM, rocky said:

Find the following code in themes/default-bootstrap/authentication.tpl at about line 492:


            <div class="required password form-group">
                <label for="passwd">{l s='Password'} <sup>*</sup></label>
                <input type="password" class="is_required validate form-control" data-validate="isPasswd" name="passwd" id="passwd" />
                <span class="form_info">{l s='(Five characters minimum)'}</span>
            </div>

and then change it to:


            <div class="required password form-group">
                <label for="passwd">{l s='Password'} <sup>*</sup></label>
                <input type="password" class="is_required validate form-control" data-validate="isPasswd" name="passwd" id="passwd" />
                <span class="form_info">{l s='(Five characters minimum)'}</span>
            </div>
            <div class="required password form-group">
                <label for="passwd">{l s='Confirmation'} <sup>*</sup></label>
                <input type="password" class="is_required validate form-control" data-validate="isPasswd" name="confirm" id="confirm_passwd" onblur="if ($(this).val() == $('#passwd').val()) $(this).parent().attr('class', 'required password form-group form-ok'); else $(this).parent().attr('class', 'required password form-group form-error');" />
            </div>

This will add a new "Confirmation" field that will turn red if the customer leaves the field and the value it doesn't match the "Password" field. If the passwords match, it will turn green.

 

You'll also need to create override/controllers/front/AuthController.php with the following to prevent an account being created when the passwords don't match:


<?php

class AuthController extends AuthControllerCore
{
    protected function processSubmitAccount()
    {
        if (Tools::getValue('passwd') != Tools::getValue('confirm')) {
            $this->errors[] = Tools::displayError('Password and confirmation do not match');
        }

        parent::processSubmitAccount();            
    }
}

This will display a "Password and confirmation do not match" error message if a customer clicks the "Register" button when the passwords don't match. Remember to go to Advanced Parameters > Performance and click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override.

Prestashop 1.6

controllers/front/AuthController.php

protected function processSubmitAccount()

just below

// Check if password matches confirmation
                if (Tools::getValue('passwd') != Tools::getValue('confirm'))
                $this->errors[] = Tools::displayError('Password confirmation does not match password !', false);

white page error area solution buukadar .. I would appreciate if our friend collects this error

Edited by alqo (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...