codeigniter form_validation_run() not returning false although it should
I have a form validation part in a controller called post;php, where the form validation should return false but it doesn't. It's probably just a typo, but after looking at it for hours, I really can't find it. I hope you can.
The first part of my controller's function called change_password looks like this:
$this->form_validation->set_rules('new','required|matches[confirm]|min_length[8]|max_length[16]');
if($this->form_validation->run()==FALSE){
$this->session->set_flashdata('msg_type','error');
$this->session->set_flashdata('msg',validation_errors('<p>','</p>'));
redirect('members#pass');
return;
}
the view that posts to the above controller looks like this. looks like this:
<h3>Update your password</h3>
<?php
echo img('update_pass.png',array("class" => "fr"));
echo form_open('post/update_pass'); ?>
<table>
<tr>
<td><?php echo form_label('Current password:','current'); ?></td>
<td><?php echo form_password('current'); ?></td>
</tr>
<tr>
<td><?php echo form_label('New password:','new')?></td>
<td><?php echo form_password('new'); ?></td>
</tr>
<tr>
<td><?php echo form_label('Retype new password:','confirm'); ?></td>
<td><?php echo form_password('confirm'); ?></td>
</tr>
<tr>
<td></td>
<td><input type='submit' value='update'&开发者_C百科gt;</td>
</tr>
</table>
</form>
The rest of the code works perfectly fine. but for example when I enter the following data
current | 'mycurrentpass'
new | jimm
confirm | rollercoaster
where both the fields don't match, and the length is too short, still the form_validation_run returns true.
The signature of set_rules
is set_rules($field, $label = '', $rules = '')
. I think you're missing a parameter.
精彩评论