valid_url rule not working |
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/>
The largest Bengali tutorial site on Web Development in this planet
There is already a question like this one on the forum: http://forum.codeigniter.com/thread-6173...=valid_url
Website: http://avenir.ro
well... localhost is also a valid url, isn't it?
Website: http://avenir.ro
(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.
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
The largest Bengali tutorial site on Web Development in this planet
(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". |
Welcome Guest, Not a member yet? Register Sign In |