Hi,
I have a dropdownlist that loads dynamically with the values of the ViewBag. The values are loaded fine. However, I added some custom validation to the dropdownlist that should be active as soon as it is load inside the control.
I have this kind of declaration.
<div class="form-group">
<label for="AreaName">Area:</label>
<div style="text-align:left;">
@Html.EJ().DropDownList("areasListMaintenance").Datasource((IEnumerable<DocTracerPortal.Models.Visual.VisualArea>)ViewBag.areasSourceMaintenance).DropDownListFields(f => f.Value("value").Text("text")).Enabled(true).EnableRTL(true).Width("70%").WatermarkText("Select an Area").ValidationRules(r => r.AddRule("required", true)).ValidationMessage(m => m.AddMessage("required", "Area required "))
</div>
</div>
<div class="form-group">
<label for="DocumentStatusName">Status:</label>
<div style="text-align:left;">
@Html.EJ().DropDownList("documentStatusListMaintenance").Datasource((IEnumerable<DocTracerPortal.Models.Visual.VisualDocumentStatus>)ViewBag.dsSourceMaintenance).DropDownListFields(f => f.Value("value").Text("text")).Enabled(true).EnableRTL(true).Width("70%").WatermarkText("Select a Status").ValidationRules(r => r.AddRule("required", true)).ValidationMessage(m => m.AddMessage("required", "DocumentCategory required "))
</div>
</div>
<div class="form-group">
<label for="DocumentCategoryName">Category:</label>
<div style="text-align:left;">
@Html.EJ().DropDownList("documentCategoriesListMaintenance").Datasource((IEnumerable<DocTracerPortal.Models.Visual.VisualDocumentCategory>)ViewBag.dcSourceMaintenance).DropDownListFields(f => f.Value("value").Text("text")).Enabled(true).EnableRTL(true).Width("70%").WatermarkText("Select a Category").ValidationRules(r => r.AddRule("required", true)).ValidationMessage(m => m.AddMessage("required", "Document Status required "))
</div>
</div>
The page load fine and I don't have any errors in the js console.
Nothing is selected, it should show the required message?
However, the control should active the required fields on load. Unfortunately, that does not seem to work.
I was checking other links in the forums and no one knows how to make it work.
https://www.syncfusion.com/forums/119669/add-validation-todropdownlisthttps://www.syncfusion.com/forums/125235/asp-net-mvc-dropdownlist-refresh-data-when-using-url-and-required-validation-ruleI added the default validation and nothing happens too.
Could you please help me with this. I do not want to make a full page load of the entire page be able to show the required messages.
Kind regards,
Juan Acosta