Welcome Guest, Not a member yet? Register   Sign In
Form Validation Error !!
#1

[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..??


#2

[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
#3

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




Theme © iAndrew 2016 - Forum software by © MyBB