Can I make a dropdown list for a form required?

Posted by Community Admin on 04-Aug-2018 18:09

Can I make a dropdown list for a form required?

All Replies

Posted by Community Admin on 13-Aug-2014 00:00

I currently see no option to do this. How can I make this a required field, preferably without custom development? Thanks.

Posted by Community Admin on 18-Aug-2014 00:00

Hi Ryan,

Actually, this is possible using a small trick. After you define your choices, set the first choice to be something like "Select a value". Then, go to Advanced settings tab, at the bottom select ValidatorDefiniton. Set the RegularExpression, for instance:

^(?!Select a Choice).*$
This will match all values starting with the entered string - the default value entered. This will force the user to select different value, making the dropdown list as if it is required. The error message shown will be the text in the RegularExpressionViolationMessage field.
This is the easiest way to achieve the 'required' dropdown, which I can think of, without custom development.
However, you should change your regular expression if you have set one, to match the not selected value as well, which is a drawback.

Regards,
Nikola Zagorchev
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 18-Aug-2014 00:00

LOL. I actually implemented this exact same approach shortly after I posted the original message. It worked perfectly. Thanks. 

Posted by Community Admin on 19-Aug-2014 00:00

Hello Ryan,

I am glad you have managed to achieve the desired functionality. Write back if we can help further.

Regards,
Nikola Zagorchev
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed