kentico document type regular expression should not fire if allow empty

Dilip Namdeo asked on April 25, 2014 06:16

Hi There,

I created a document type and having a text field to capture website URL as it's not mandatory field so I have checked "Allow empty value" to true but I'd like ensure if any user entering the value in this filed, that must a valid URL. To achieve it I used the "Regular expression" option.

Now problem is that, entered Regular expression still firing even user not entering any value. what I want my Regular expression should fire if there is any value user entering otherwise not.

Any help would be appreciate!

kind Regards Dilip

Recent Answers


Brenden Kehren answered on April 25, 2014 07:48

Technically an empty string is not a valid URL. So your regular expression will have to accommodate for that.

You could also use a URL selector as a control type vs. a textbox. Using this you can configure this to allow or not allow someone to choose attachments, content tree items, media library items and/or a website URL. It makes it easier for someone to enter or select a link.

0 votesVote for this answer Mark as a Correct answer

Dilip Namdeo answered on April 25, 2014 08:05

Hi Brenden,

Thanks for your reply!

I tried to use URL selector apart from text box but it's not validate the input means a valid URL formate.

Could you please let me know if there is any additional setting I need to do.

Thanks

0 votesVote for this answer Mark as a Correct answer

Petr Dvorak answered on April 25, 2014 09:31

Hi Dilip,

you can try regular expression such as ^($|https?://.*$). Update the inner condition as you need to match desired format.

1 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 25, 2014 22:50

You are correct Dilip, it does not validate the URL ALTHOUGH it does give the user something to select from VS manually typing in which will give you better results than you'd expect. The user will find out pretty quick if their link is broken.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.