我有我想用笨Form_Validation
類驗證此HTML代碼:笨驗證複選框組
<form id="thread" method="POST">
<input type="checkbox" name="checkAllAuto" id="checkAll" onclick="CheckAll(this.id)" /><?php echo __t($dir_lang,'request_select_all');?>
<br />
<?php foreach ($threads as $thread): ?>
<input type="checkbox" class="threads" name="option[]" value="<?php echo $thread['th_id']; ?>" /> <?php echo $thread['th_title']; ?> <br>
<?php endforeach; ?>
<br />
<input type="checkbox" name="mom" /> <?php echo __t($dir_lang,'request_send');?>
<br />
<select name="cat">
<?php foreach ($cats as $cat): ?>
<option value="<?php echo $cat['id']; ?>"> <?php echo $cat['title']; ?> </option>
<?php endforeach; ?>
</select>
<br /><input type="submit" value="<?php echo __t($dir_lang,'submit');?> " /><br>
</form>
我試圖驗證複選框的拳頭組通過使用Form_Validation
if ($this->input->isMethodPost())
{
$this->tplData['showMess'] = true;
$this->load->library('form_validation');
$this->lang->load('form_validation', 'english');
$this->form_validation->set_error_delimiters('<h3>', '</h3>');
$this->form_validation->set_rules('options[]','options', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->tplData['showError'] = true;
$this->tplData['mess'] = array(validation_errors());
}else{
// my work
}
}
它提供了所需的歸檔消息,但即使我選擇了一個或所有複選框,仍然會提供所需的消息。在你的代碼
有沒有人可以幫助我? –
@SebastianWolff –