Welcome Guest, Not a member yet? Register   Sign In
Form Validation To Check Min and Max values in two fields
#1

[eluser]hema[/eluser]
Hi All,

I am having a form which is having min_cost and max_cost as two fields. max_cost field value should always be bigger than min_cost. How can i do this CI validation

Following is my code

Code:
$this->form_validation->set_rules('cost-min', 'Cost Min', 'required|numeric'); // should always be lower than cost-max
$this->form_validation->set_rules('cost-max',  'Cost Max', 'required|numeric'); // should always be higher


// above validation is normal one check if the fields are empty. Below code is to check which value is higher

if( $this->input->post('cost-min') >  $this->input->post('cost-max'))
   {
    $this->form_validation->set_message('cost-max', 'Your validation message.');
   }

Above code is not working, is there anything i can do?


Messages In This Thread
Form Validation To Check Min and Max values in two fields - by El Forum - 03-23-2013, 07:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB