cakephp-routing

How do I validate URL, but ignore if http:// or blank?

China☆狼群 提交于 2020-01-04 05:45:12
问题 I want to validate a form field for URL. I have set the default for the field to http://. When the user doesn't enter a URL, and leaves the http://, it says invalid URL. URL is not required, so if it's only http://, it should not show error message. How can I make it ignore if the person submits http:// as the URL? Thanks 回答1: http:// is not a valid url, so if you want to allow it anyway there are 2 options create a custom validation rule, that returns true for a real url + http:// use the