phpcodeignitercodeigniter-3server-side-validation

CodeIgniter form validation does not work for url


I used form_validation for validate URL by using this code:

 $this->form_validation->set_rules("edtQuestionURL", "Site URL", "trim|required|url");

But every time I run my code, It returns false.

What is my mistake? I made some change in system/Form_validation.php file (I got them from StackOverflow) but it does not work. Please guide me.


Solution

  • Maybe you can try like this

    $this->form_validation->set_rules("edtQuestionURL", "Site URL", "trim|required|valid_url");
    

    or this

    $this->form_validation->set_rules("edtQuestionURL", "Site URL", "trim|required|prep_url");