Welcome Guest, Not a member yet? Register   Sign In
CI form validation with input data

I have form which contain no of participant appeared and passed two text box.

In ci form validation how can i check passed participant should not be greater than the appeared. Please help me.

You could use a callback.


Then in the callback function get the two post values, compare them, and if not correct, set an error message for the callback rule name.

The form validation library has a rule for that.
Let's say the passing participant is field name "part_passing" and the appearing one has field name "part_appearing", then set the rules as follows:
PHP Code:
$this->form_validation->set_rules('part_passing','Passing participant','required|less_than_equal_to[part_appearing]');
$this->form_validation->set_rules('part_appearing','Appearing participant','required'); 

This makes both fields required, and the passing participant must be less than or equal to the appearing participant (which is the same is "not greater than"). Probably in your case, 'less_than' is better, to ensure that both fields will not be the same.

See documentation about the form validation library:

@Wouter 60

Thank you so much

Theme © iAndrew 2016 - Forum software by © MyBB