Input Type URL - Says "Please enter a URL" if HTTP is not included

Viewed 13701

I've been working on a form and run into a snag. I've been using input type="url" so that iPad and iPhones etc all pull up the correct keyboard - and to try and follow the new standards.

I've run into an issue though. On a form where the web address is not required - if a user types in www.theiraddress.com most browsers outline it in red/yellow to notify the user they need to enter "http://" before it.

I've used input:invalid css to remove that outline.

However now when the user submits the form, the browser throws an error saying "Please enter a URL".

The field isn't required - I just wanted to make it easier for folks to enter their addresses - but still display the right keyboards on mobile devices etc.

Is there a way to remove this annoying tooltip that prevents users from submitting the form?

4 Answers

As far as I know, according to the standard, the protocol is required (Url input field implementation state). You could alternatively use a regexp to validate that field such as /^(?:(http|https|ftp):\/\/)?(?:[\w-]+\.)+[a-z]{2,6}(\/)?/i

Related