hozza
hozza

Reputation: 630

HTML5 URL Input Box without Protocol

When you use a input type of url instead of the standard text. Firefox 4 will not submit the form without http:// or https:// in the input box.

All I'm after is a URL without the protocol such as www.google.com not http://www.google.com. Is there a parameter to do this or any other way (preferably without JavaScript)?

Upvotes: 10

Views: 2974

Answers (2)

schpet
schpet

Reputation: 10620

use the html5 novalidate attribute on the form, e.g.

<form method="post" novalidate>
   ...
</form>

this will give you the nice keyboard on mobile devices and let you do your own validation

https://www.w3.org/TR/html5/sec-forms.html#element-attrdef-form-novalidate

Upvotes: 3

generalopinion
generalopinion

Reputation: 1437

I use RegExr for all my regular expression creation needs. They have a number of pre-defined regular expressions.

You might be able to reverse engineer this a little: (https?://)?(www\.)?([a-zA-Z0-9_%]*)\b\.[a-z]{2,4}(\.[a-z]{2})?((/[a-zA-Z0-9_%]*)+)?(\.[a-z]*)?

Upvotes: -1

Related Questions