开发者

how to add a custom validation , codeigniter

开发者 https://www.devze.com 2023-04-13 05:55 出处:网络
hi i am using codeigniter , i use codeigniterform validation . i have a input called pric开发者_StackOverflow社区e

hi i am using codeigniter , i use codeigniter form validation . i have a input called pric开发者_StackOverflow社区e

<input id="Price"  name="price" class="textbox-small Verdana11-424039" type="text" name=""
 tabindex="1900" />

i validate price like this

this->form_validation->set_rules('price', 'Price', 'trim|required'); 

but i want to validate price to take only numbers , commas and dots

like this .

1000
1000.00
1,000.00

how can a custom validation like this accomplished by codeigniter , please help......


There is a callback function option when using form validation in codeigniter. You can write your own function inside the controller which checks for your price using regex, and then you can set that function/method as the callback function name when you set form validation rules.

You can read more at http://codeigniter.com/user_guide/libraries/form_validation.html#callbacks

0

精彩评论

暂无评论...
验证码 换一张
取 消