[eluser]missionsix[/eluser]
use an if statement to check if the fields are filled, before you build your requirements. As such:
Code:
<?php
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<p class="error">', '</p>');
if(empty($this->input->post('zipcode')) {
$this->form_validation->set_rules('city', 'City', 'trim|required');
$this->form_validation->set_rules('state', 'State', 'trim|required');
} else {
$this->form_validation->set_rules('zip', 'Zip Code', 'trim|required');
}
if($this->form_validation->run()=== false) {
// display errors
} else {
//save form
}
?>
Rules are set after the form is sent to the browser, so you still have access to $_POST vars from there in ($this->input->post(KEY); ). Hope that helps.