1

I have to show required error message, if i'm selecting default text in dropdownlist, Is there any option to show this validation message.

enter image description here

0

Modify DropdownList.cshtml found under C:\inetpub\wwwroot\yoursite.dev.com\Views\FormBuilder\FieldTemplates

Update the following

@foreach (var item in Model.Items)
{
    <option value="@item.Value" selected="@item.Selected">@item.Text</option>
}

with the follwing

@foreach (var item in Model.Items)
{
    <option value="@item.Value.Trim()" selected="@item.Selected">@item.Text</option>
}

Instead of "0", I have just validated on empty value(value should be space). Since there could be possibilty of using "0" elsewhere.

| improve this answer | |
0

You can set the following option for this control in the form builder:

Validation -> Field importance: Mandatory.

Next, for the "Select..." option you can set the value as " " - so it would be saved by the form editor.

So now if the "Select..." option is selected, on the form submission this control will be marked with a "required" error message.

Another possible option would be to create a custom drop-down (copy on existing one) control with custom validation and custom parameter for empty option value - like "0" as on your screens shot.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.