Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm trying to use validation on an input field in Umbraco to see if the user has entered http:// or https:// in the beginning of a textstring. The regexp I'm using looks like this:
It works if http:// or https:// is the only thing you put in the field, but if you enter a real URL (http://www.mydomain.com), it says it's not the correct format. Using a regexp tester, it seems like the syntax is correct though?
Is it my regexp code that is not correct or is it how Umbraco interprets it?
Thanks in advance!
I would suggest always making sure the regex matches the whole input, and include the end character "$"
That regex doesn't allow anything after the http or https. Depending on what you want to achieve, you will need to decide what other characters are going to be allowed. Try:
This allows 1 or more letters, numbers and symbols that are allowed in a URL (not tested - but it looks right)
The following should allow absolutely anything after the http:// or https:// (or even nothing) except for newline characters
When I tried using this regex:
...with the link http://www.test.com, Umbraco says it's not a correct format. This one works though:
Thanks for the reply!
Hi Thomas - it seems I was having some sort of brain fart - ther is no need of the square brackets round the "." in the basic regex - but it is a pretty daft regex anyway - as all it does is enforce that the string starts with http(s):// - amd allows spaces and pretty much all other non-uri compliant characters. If you relly want such a regex this is it:
I just want to prevent administrators from entering incomplete links like "www.test.com" - omitting the http or https prefix. Since browsers can handle links that don't start with "http" users often assume that it's OK to omit it in link fields in CMS's as well. Otherwise I trust that they get the rest right. :-)
Thanks again for sorting this out!
Thank you guys. Just what I needed.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted