脚本宝典收集整理的这篇文章主要介绍了php – 是否可以使用或在codeigniter表单验证?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
$this->form_validation->set_rules('PRice','Price','decimal|numeric');
但我认为form_validation帮助器中的规则不能使用“或”语句.如果价格是“149.99”那么它是有效的,但如果价格是“150”则不是.
我错过了什么或不可能使用这样的东西:
$this->form_validation->set_rules('price','decimal or numeric');
声明这样的规则
$this->form_validation->set_rules('price','callback_decimal_numeric');
在控制器上创建方法后
public function decimal_numeric($str) { if ($str <isdecimal&nummeric>) //Use your LOGic to check here { $this->form_validation->set_message('decimal_numeric','The %s field validation has Failed'); return FALSE; } else { return TRUE; } }
以上是脚本宝典为你收集整理的php – 是否可以使用或在codeigniter表单验证?全部内容,希望文章能够帮你解决php – 是否可以使用或在codeigniter表单验证?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。