I made a custom function for my form validation in Codeigniter. Its hooked to the URL Helper, i achieved this by making a MY_url_helper.
The helper modification:
function valid_url($str) {
$pattern = "/^(http|https):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i";
if (preg_match($pattern, $str)) return TRUE;
else return FALSE;
}
/* End of file MY_url_helper.php */
/* Location: ./application/helpers/MY_url_helper.php */
How i call the validation:
$this->form_validation->set_rules('image', 'Image path', 'valid_url');
The language file:
$lang['valid_url'] = "The %s field must contain a valid URL.";
/* End of file form_validation_lang.php */
/* Location: ./system/language/english/form_validation_lang.php */
But it doesn't show any error message when submitting the form. If i change the valid_url function to echo something on true and false, it will execute that. So it runs the function.
How can i make the error message appear?