编码器点火器未验证输入文本


input text is not validated by codeigniter

我有一个密码更改表单,提交时只验证了两个输入,并且没有验证名称为"确认新密码"的输入。 我错了什么?

请帮助我。

HTML 和 JS 代码

$(function($) {
    $.fn.ajaxForm = function(url, data, msgHolderId) {
        var self = this;
        var result;
        return $(self).bind('submit', function(e) {
            e.preventDefault();
            if (data != null)
                data = "&" + $.param(data);
            alert(data);
            $.ajax({
                url: '<?= base_url() ?>' + url,
                async: false,
                cache: false,
                data: $(self).serialize() + data,
                type: 'POST',
                dataType: 'json',
                success: function(response) {
                    $('#' + msgHolderId).html(response.msg);
                }
            });
        });
    }
}(jQuery));
$(document).ready(function() {
    $('#password-change-form').ajaxForm('user/settings/password_change', null, 'msg-holder');
});

我的网页表单

<form id="password-change-form">
    <table class="table table-bordered table-responsive table-condensed table-hover">
        <tr>
            <td colspan="3" style="background-color: #e8e8e8">Password Update</td>
        </tr>
        <tr>
            <td style="width:20%">Current password</td>
            <td style="width:50%"><input type="password" class="form-control" name="current-password" id="current-password" /></td>
            <td></td>
        </tr>
        <tr>
            <td style="width:20%">New Password</td>
            <td style="width:50%"><input type="password" class="form-control" name="new-password" id="new-password" /></td>
            <td></td>
        </tr>
        <tr>
            <td style="width:20%">Confirm new password</td>
            <td style="width:50%"><input type="password" class="form-control" name="confirm-new-password" id="confirm-new-password" /></td>
            <td></td>
        </tr>
        <tr>
            <td style="width:20%"></td>
            <td colspan="2" style="width:50%"><input type="submit" class="btn btn-default" value="ذخیره تغییرات" /></td>
        </tr>
    </table>
</form>

服务器端代码

$this->form_validation->set_rules('current-password', 'A', 'trim|callback_password_check');
$this->form_validation->set_rules('new-password', 'B', 'trim|required|min_length[8]');
$this->form_validation->set_rules('confirm-new-password', 'C', 'trim|matches[new-password]');
if($this->form_validation->run())
    $this->Common_db_actions_model->update_data('users' ,array('password' => $hash_new_password) ,array('user_id' => $this->active_user['user_id']));

试试这个

$this->form_validation->set_rules('password', 'Password', 'required|matches[confirm-new-password]');
$this->form_validation->set_rules('confirm-new-password', 'Password Confirmation', 'required');

试试这段代码:

$this->form_validation->set_rules('current_pwd', 'Current password','required');
$this->form_validation->set_rules('new_pwd', 'New password' ,'required|min_length[6]|max_length[20]');
$this->form_validation->set_rules('confirm_pwd', 'Confirm password','required|matches[new_pwd]');

然后更改输入名称。