![]() |
Help setting this validation rule - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Help setting this validation rule (/showthread.php?tid=42411) |
Help setting this validation rule - El Forum - 06-06-2011 [eluser]ReyPM[/eluser] Hi every: I need to validate that a value inserted is integer and also not less than 40 and not more than 100, any help? how to set this rules using form_validation library? Help setting this validation rule - El Forum - 06-06-2011 [eluser]cideveloper[/eluser] The manual has this information but ill be nice Code: $this->form_validation->set_rules('field', 'Field', 'integer|greater_than[39]|less_than[101]'); Help setting this validation rule - El Forum - 06-06-2011 [eluser]ReyPM[/eluser] Ohh you're right thanks I miss this part but I've another problem related to this. 1) How you build a rule for this: Code: ($value < 40 || $value > 100 || $value != 0) Code: $this->validation->set_rules("hp_motor", "HP Motor", "required|numeric|integer|min_length[40]|max_length[300]"); Help setting this validation rule - El Forum - 06-06-2011 [eluser]theprodigy[/eluser] Quote:1) How you build a rule for this:I believe what cideveloper gave you should handle it. It it must be greater than 39, 0 doesn't fit the bill. Help setting this validation rule - El Forum - 06-06-2011 [eluser]cideveloper[/eluser] [quote author="ReyPM" date="1307425639"]Ohh you're right thanks I miss this part but I've another problem related to this. 1) How you build a rule for this: Code: ($value < 40 || $value > 100 || $value != 0) Code: $this->validation->set_rules("hp_motor", "HP Motor", "required|numeric|integer|min_length[40]|max_length[300]"); 1) Look at is_natural_no_zero, greater_than and less_than 2) Completely wrong from what I can see. No need to do numeric and integer. min and max length deal with strings. greater_than and less_than deal with numbers. go through the Rule Reference. It has all the options you require. |