Skip to content Skip to sidebar Skip to footer

Confirm The Password Before A Form Submit In Laravel

I am using Laravel 4.2 and I want to confirm the user's password before a form submit with something like a modal, without doing the actual submit. If the password matches, do the

Solution 1:

Add this in your model:

publicfunctionafterValidate() {
        if (count($this->errors()->toArray())==0 && !empty($this->password) && $this->password!=$this->getOriginal('password')) {
            $this->password = Hash::make($this->password);  // encrypting the passwordunset($this->password_confirmation);    // dropping password confirmation field
        }
    }

This in your rules:

'password' => 'Required|alpha_num|between:6,12|confirmed',
'password_confirmation' => 'Required|alpha_num|between:6,12|same:password',

See, if that helps.

Solution 2:

Get the submit button ID, override the onclick() with your own code, bring up your modal that confirms the password, and return false so the form doesn't actually get submitted. When the user clicks OK on your modal, if the password matches then do a form submit from JS.

Post a Comment for "Confirm The Password Before A Form Submit In Laravel"