Welcome Guest, Not a member yet? Register   Sign In
Help setting this validation rule
#1

[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?
#2

[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]');
#3

[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)
2) How do I check that is a integer and also that is positive value? This is right:
Code:
$this->validation->set_rules("hp_motor", "HP Motor", "required|numeric|integer|min_length[40]|max_length[300]");
#4

[eluser]theprodigy[/eluser]
Quote:1) How you build a rule for this:
Code:
($value < 40 || $value > 100 || $value != 0)
I believe what cideveloper gave you should handle it. It it must be greater than 39, 0 doesn't fit the bill.
#5

[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)
2) How do I check that is a integer and also that is positive value? This is right:
Code:
$this->validation->set_rules("hp_motor", "HP Motor", "required|numeric|integer|min_length[40]|max_length[300]");
[/quote]

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.




Theme © iAndrew 2016 - Forum software by © MyBB