lundi 5 septembre 2016

How do I create a required pattern in HTML5 to only allow certain extensions in a website field

Just dabbling with learning some required patterns in HTML5 and can't quite get my head around how to do this particular thing.

What would a pattern look like that requires a user to input a URL in the format of http://ift.tt/2cgSUnt, but can only use extensions .com, .net, or .org?

I went ok with using very simple patterns, but am stumped on this.

An example I found on a site was this:

required pattern=^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$

But this doesn't seem to be able to meet the requirements I listed above, but I also can't quite interpret that pattern as I'm still just learning this.

Thanks!

Aucun commentaire:

Enregistrer un commentaire