We have a cool feature in HTML5 validating website url with declarating input type=”url”. This feature is supported in almost every browser.
Below html5 input tag like below will validate url for both protocols http and https with validating domain extension i-e .com, .co etc.
<input
type="url"
name="website"
placeholder="Website URL: http(s)://example.com"
pattern="[Hh][Tt][Tt][Pp][Ss]?:\/\/(?:(?:[a-zA-Z\u00a1-\uffff0-9]+-?)*[a-zA-Z\u00a1-\uffff0-9]+)(?:\.(?:[a-zA-Z\u00a1-\uffff0-9]+-?)*[a-zA-Z\u00a1-\uffff0-9]+)*(?:\.(?:[a-zA-Z\u00a1-\uffff]{2,}))(?::\d{2,5})?(?:\/[^\s]*)?"
required
/>
The following url patterns it will validate:
https://example.com
http://example.com
https://www.example.com
http://www.example.com
A list of the best spas in Dubai that will relax your body and mind…
Canada is a majestically beautiful country full of natural wonders and is also home to…
Here is a list of the Best USA Makeup Brands in 2023, that are safe…
Here is a list of the Best Australian Makeup Brands in 2023, that are safe…
Content creators always try hard to make their content reach a large number of followers…
Truck companies are constantly searching for people to fulfill their logistics, transportation, and supply chain…