I have the following listbox with validator that will not validate properly. It shows invalid no matter if it is empty or populated. The only way I can get it to validate is to select an item in the listbox. If it helps LBvalue seems to always be null even when I select an item. Any Ideas?
<RadzenListBox class="form-control form-text-custom" Name="LBDates" @bind-Value=@LBvalue Data="@dates" Style="height:115px; width:205px" Change=@(args => OnLBChange(args, "ListBox"))></RadzenListBox>
<RadzenRequiredValidator Component="LBDates" Text="Atleast 1 date is required" Popup="true" Style="position: relative;" />
Since i got no bites I guess i should rephase my question:
How do I validate a listbox and a select? Can it be done? I've tried the required and length validator and neither work. Can someone post an example?
Here is a minimal example based on our demo:
<RadzenTemplateForm Data=@("Data")>
<RadzenListBox Name="Customer" @bind-Value=@value Data=@customers
TextProperty="CompanyName" ValueProperty="CustomerID"/>
<RadzenRequiredValidator Text="Customer is required"
Component="Customer" />
<RadzenButton ButtonType="ButtonType.Submit" Text="Save" />
</RadzenTemplateForm>
@code {
string value = null;
IEnumerable<Customer> customers;
protected override void OnInitialized()
{
customers = dbContext.Customers.ToList();
}
}