![]() |
valid_url rule not working - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: valid_url rule not working (/showthread.php?tid=61802) |
valid_url rule not working - rejoan - 05-19-2015 form validation rule "valid_url" not working as expected. here is my code PHP Code: $this->form_validation->set_rules('website', 'Website', 'required|valid_url'); this rule returning true for string "test" for following markup PHP Code: <input type="text" class="form-control" id="website" name="website" placeholder="Website Address" required/> RE: valid_url rule not working - Avenirer - 05-19-2015 There is already a question like this one on the forum: http://forum.codeigniter.com/thread-61734.html?highlight=valid_url RE: valid_url rule not working - rejoan - 05-19-2015 any string treating as valid. "test","spinytel", "rejoan" all are tested. returning true & form submitting RE: valid_url rule not working - Avenirer - 05-19-2015 well... localhost is also a valid url, isn't it? RE: valid_url rule not working - mwhitney - 05-20-2015 (05-19-2015, 03:33 AM)rejoan Wrote: any string treating as valid. "test","spinytel", "rejoan" all are tested. returning true & form submitting ...because those are valid URLs. Try using a character which is not permitted in a URL, or an invalid structure for the URL. I'm not sure how good the validation is, but I'm sure that your examples so far have all been valid URLs. You're clearly looking for a validation which does something else, probably more explicit than simply determining whether it is a valid URL. RE: valid_url rule not working - rejoan - 05-20-2015 In fact i need a rules which will return true only when find URL like these "google.com", "www.google.com", "http://google.com" etc but return false when not a valid a web address RE: valid_url rule not working - mwhitney - 05-21-2015 (05-20-2015, 11:41 PM)rejoan Wrote: In fact i need a rules which will return true only when find URL like these "google.com", "www.google.com", "http://google.com" etc but return false when not a valid a web address Your best bet in this case would probably be to create a custom validation function which calls the valid_url() method, then performs additional checks if the valid_url() method returns true. The first resource for determining what makes up a valid URL is often RFC 3986, but I don't think you'll find this very helpful for whatever you need to do to determine what input represents a "valid web address". |