i having a function called website_check
function website_check($url){
if ($url !=""){
if (preg_match("#^https?://.+#", $url) and fopen($url,"r")){
return TRUE;
}else{
$this->form_validation->set_message('Website url', 'The %s field is invalid');
return FALSE;
}
}else{
$this->form_validation->set_message('Website url', 'The %s field is required');
return FALSE;
}
}
and i use this function as a custom code-igniter form validation function
$this->form_validation->set_rules('website', 'Website', 'callback_website_check');
i am using this function in every controller, so i want to add this function into codeigniters form validation class and use as a default validation function. is it possible to add your function to codeigniters form validation class,if it is how it can be done ?
Edit the file ‘system/libraries/Form_validation.php’ and insert this new function to the class “CI_Form_validation”.
And then edit the file ‘language/english/form_validation_lang.php’ and append this item:
then use it as :