Javascript codeigniter未验证输入文本
我有一个密码更改表,提交时只有两个输入被验证,名为“确认新密码”的输入未被验证。我怎么了 请帮帮我 HTML和JS代码Javascript codeigniter未验证输入文本,javascript,php,jquery,codeigniter,validation,Javascript,Php,Jquery,Codeigniter,Validation,我有一个密码更改表,提交时只有两个输入被验证,名为“确认新密码”的输入未被验证。我怎么了 请帮帮我 HTML和JS代码 $(function($) { $.fn.ajaxForm = function(url, data, msgHolderId) { var self = this; var result; return $(self).bind('submit', function(e) { e.preventD
$(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');
});
试试这个
$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]');
然后更改输入名称
$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]');