php - How to use same callback function for multiple text fields in codeigniter -


i want check if value other integer , float, have written form validation follows,

$this->form_validation->set_rules('charge_hour', 'per hour', 'xss_clean|callback_money_type'); $this->form_validation->set_rules('charge_day', 'per day', 'xss_clean|callback_money_type'); $this->form_validation->set_rules('charge_weekly', 'per week', 'xss_clean|callback_money_type'); $this->form_validation->set_rules('charge_monthly', 'per month', 'xss_clean|callback_money_type'); 

and common call function text filed money_type()

    public function money_type($charge)         {             if (is_float($charge) == false && is_int($charge) == false && $charge >= 0)             {                 $this->form_validation->set_message('{what enter here}', 'enter valid charges space.');                 return false;             }         else         {             return true;         }     } 

how can find out during validation {what enter here}? field name either of charge_hour, charge_day, charge_weekly, charge_monthly @ runtime? form validation show different error messages each field.

thanks.

$this->form_validation->set_message('money_type','%s message'); 

https://ellislab.com/codeigniter/user-guide/libraries/form_validation.html#callbacks


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -