简体   繁体   English

Codeigniter表单验证great_than

[英]Codeigniter Form Validation greater_than

$this->form_validation->set_rules('start_price', 'Starting Price', 'required|decimal');
$this->form_validation->set_rules('price', 'Price', 'trim|required|decimal|greater_than[start_price]');

I have this code. 我有这个代码。 Even i input a price greater than my start_price still the output is The Price field must contain a number greater than Starting Price. 即使我输入的价格大于我的start_price,输出仍然是The Price字段中必须包含大于起始价格的数字。

The code looks fine to me unless there's any silly mistake. 除非有任何愚蠢的错误,否则代码对我来说看起来不错。 Try using less_than in Starting Price. 尝试在起始价格中使用less_than。 Silly, I know, but you could give it a try. 我知道这很傻,但是您可以尝试一下。

Try to get value of the start price first, then validate. 尝试先获取起始价格的价值,然后进行验证。

$start_price = $_POST[start_price];
$this->form_validation->set_rules('start_price', 'Starting Price', 'required|decimal');
$this->form_validation->set_rules('price', 'Price', "trim|required|decimal|greater_than[$start_price]");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM