验证即使在正确的条件下也会失败

时间:2017-07-20 09:02:39

标签: php codeigniter

我在这里遇到了codeigniter表格验证。以下是我的代码。

$match_data = $this->input->post('match_data');

        $this->load->library('form_validation');

        foreach($match_data as $roundno => $round_data) {
            foreach ($round_data as $roundtimes => $round_times_data) {
                foreach ($round_times_data as $match_no => $match) {
                    foreach ($match as $games_times => $games) {
                        $this->form_validation->set_rules("match_data[".$roundno."][".$roundtimes."][".$match_no."][".$games_times."][score1]", "score1", "trim|xss_clean|numeric");
                        $this->form_validation->set_rules("match_data[".$roundno."][".$roundtimes."][".$match_no."][".$games_times."][score2]", "score2", "trim|xss_clean|numeric");
                    }
                }
            }
        }

当我提交a,b,c或类似的任何内容时,验证检查没问题。但是一旦我输入正确的数值,它仍然显示我的错误。请帮我查一下这个问题?这是我的输入文件代码

<div class="row">
    <div class="col-sm-6">
            <input class="form-control" type="text" name="match_data[<?php echo $edit_round_num; ?>][<?php echo $matchtime; ?>][<?php echo $match; ?>][<?php echo $gametime+1; ?>][score1]" value="<?php echo $games_per_match_array_one[$gametime]; ?>" />
</div>
                                                                                                <div class="col-sm-6">
    <input class="form-control" type="text" name="match_data[<?php echo $edit_round_num; ?>][<?php echo $matchtime; ?>][<?php echo $match; ?>][<?php echo $gametime+1; ?>][score2]" value="<?php echo $games_per_match_array_two[$gametime]; ?>" />
                                                                                                </div>
                                                                                            </div>

1 个答案:

答案 0 :(得分:0)

如果验证numeric值验证trim|xss _清洁不起作用或需要。因此,一旦删除trim|xss_clean,代码就会开始工作。