Welcome Guest, Not a member yet? Register   Sign In
password matches not working

(This post was last modified: 08-01-2017, 10:02 AM by nullstrike. Edit Reason: typo error )

I'm stuck in this part. Everytime I correctly inputted the two fields with the same value it always returning password does not match.
I'm using ajax btw
Here's my controller:
$this->form_validation->set_rules("password", "password", "required");
        $this->form_validation->set_rules("passwordconf", "password confirm", "matches[password]");
        $data = array('userPassword' => password_hash($this->input->post('password'), PASSWORD_BCRYPT));
        if ($this->form_validation->run()) {
            $id = $this->input->post('id');
            $response['success'] = true;
            $response['message'] = "Successfully updated user password";
            $response['page'] = base_url();
            $this->user_model->userupdate($id, $data);
            $response['id'] = $id;
            $response['data'] = $data;
        } else {
            $response['success'] = false;
            $response['errors'] = $this->form_validation->error_array();

Here's my ajax code: 
    var userID = $('#userID').val();
    var password = $('#password').val();
        url: site_url('user/userUpdate'),
        data: {id: userID, password: password},
        type: 'post',
        dataType: 'json',
        success: function(response){
            if(response.success === true){
                Materialize.toast(response.message, 2000, 'green');
                setTimeout(function(){window.location.href = response.page;},3000);
                if(response.success === false) {
                    if (response.errors) {
                        $.each(response.errors, function (key, val) {
                            $('input[name="' + key + '"]').next().html(val).addClass('has-error');

My view: 
<div class="row" id="login-box" style="padding-top:140px">
    <div class="col s4 offset-s4">
        <div class="z-depth-5 card-panel blue-grey darken-4 white-text">
            <h4 class="center">Change your password</h4>
            <form autocomplete="off" id="changePassForm">
                <div class="row">
                    <input type="hidden" id="userID" value="<?php echo $this->session->userdata('userID');?>">
                    <div class="input-field col s12">
                        <label for="last_name">Username</label>
                        <input id="username" name="username" type="text" style="font-size: 1.3rem;" class="" readonly value="<?php echo $this->session->userdata('userName');?>">
                        <span class="red-text"></span>
                    <div class="row">
                        <div class="input-field col s12">
                            <label for="password">New Password</label>
                            <input id="password" name="password" type="password" class="validate">
                            <span class="red-text"></span>
                        <div class="input-field col s12">
                            <label for="passwordconf">Confirm Password</label>
                            <input name="passwordconf" type="password" class="validate">
                            <span class="red-text"></span>
                    <div class="row" style="margin-bottom: 0px;">
                        <button type="submit" id="btn_changepass" class="btn red darken-4 waves-effect waves-light col s12"> Change Password</button>

I seem no error IMO. Where do I get wrong here.

Messages In This Thread
password matches not working - by nullstrike - 08-01-2017, 09:55 AM
RE: password matches not working - by jarmen_kell - 08-01-2017, 07:08 PM

Theme © iAndrew 2016 - Forum software by © MyBB