CodeIgniter Forums
Form Validation Error !! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Form Validation Error !! (/showthread.php?tid=48507)



Form Validation Error !! - El Forum - 01-19-2012

[eluser]Vaibhav132[/eluser]
To validate an url i am using the following callback method
Code:
function validate_url($url){
   $result = @file_get_contents($url);
   if($result == false){
   $this->form_validation->set_message('refurl', 'Enter valid URL');
   return false;
  }
  else{
   return true;
  }
}

If user inserts invalid url ..the following message is thrown

"Unable to access an error message corresponding to your field name."

instead of the one i have set "Enter valid URL".

Is it because i am suppressing file_get_contents function..??





Form Validation Error !! - El Forum - 01-19-2012

[eluser]Philip Kavanagh[/eluser]
change:
$this->form_validation->set_message('refurl', 'Enter valid URL');

to:
$this->form_validation->set_message('validate_url', 'Enter valid URL');


Instead of using callbacks, to me at least it makes more sense to extend CI_FORM_Validation



Form Validation Error !! - El Forum - 01-19-2012

[eluser]Vaibhav132[/eluser]
@Philip..
Thanks dude..
Wondering how can i do such silly mistake...