after experimenting i got a solution to add second argument in custom validator function definition.
public function isNotPastDate($str,$parameter){ #Loading CI Instance $CI = & get_instance(); $CI->load->database(); #setting up the initiator filed name and data. $date = $CI->input->post($parameter, true); $fieldname = ($parameter == 'to')?"To":"From"; if ((date('Y-m-d', strtotime($date)) < date('Y-m-d'))) { $CI->form_validation->set_message('isNotPastDate', $fieldname.' Date is a Past date.'); return false; } else { return true; } }
with the rule config :
array( array( 'field' => 'from', 'label' => 'From Date', 'rules' => 'required|trim|xss_clean|dateRangeValidation|isNotPastDate[from]' ), array( 'field' => 'to', 'label' => 'To Date', 'rules' => 'required|trim|xss_clean|isNotPastDate[to]' ),);