- Home
- Forum
- ASP.NET Core
- Validation message is not showing
Validation message is not showing
Hi Support:
I need to include client side validation to my form that has several dropdownlist control in asp.net core.
My problem is that the validation works but the error message is not being displayed.
I tested your sample:
https://www.syncfusion.com/forums/128816/asp-net-core-validation-tag-helper-is-ignored-for-the-ej-drop-down-list
and works fine, but inside my web application is not working. In my application I am using bootstrap, no idea if this could be creating this issue. The strange thing is that no errors in the console.log
This is definition of a control:
<ej-drop-down-list id="Service" name="Service" width="100%" popup-height="100px" show-rounded-corner="true"
datasource="@Model.Services" watermark-text="Select"
validation-rules='new Dictionary<string, object>() { { "required",true} }'
validation-message='new Dictionary<string, object>() { { "required","value required"} }' >
<e-drop-down-list-fields text="Name" value="ID" />
</ej-drop-down-list>
<script type="text/javascript">
$.validator.setDefaults({
ignore: [], // To include hidden input validation.
errorClass: 'input-validation-error', // to get the error message on jquery validation
errorPlacement: function (error, element) {
$(error).insertAfter(element.closest(".e-widget"));
}
});
</script>
This is the rendered view of the control:
<input type="hidden" id="Service" class="e-dropdownlist e-js input-validation-error" tabindex="" value="" role="combobox" aria-expanded="false" aria-autocomplete="list" aria-haspopup="true" aria-owns="Service_popup" style="display: none;" name="Service" aria-required="true" aria-describedby="Service-error">
What could I be missing here that is causing that the error message is not being displayed.
Thanks in advance.
David
SIGN IN To post a reply.
3 Replies
PO
Prince Oliver
Syncfusion Team
May 18, 2017 09:12 AM UTC
Hi David,
Thank you for contacting Syncfusion support.
We have prepared a sample with your class “input-validation-error” for validation error in Dropdownlist validation sample. Kindly refer to the following link for the sample: http://www.syncfusion.com/downloads/support/forum/130520/ze/CoreDropdownlist-1542162588
If the issue persists at your end, please modify the above sample to reproduce the issue and revert it to us. It will help us isolate the root cause and provide solution.
Regards,
Prince
DS
dsapo
May 19, 2017 04:20 AM UTC
Hi Prince:
I found the issue but I dont know how to handle it.
My form also has a hidden field like this:
@Html.HiddenFor( model=> model.ProductID)
This renders validation attributes because in my model this property has the [Required] annotation.
Also, my form has a couple of @HtmlEditorFor that are affecting the setDefaults in a similar way as the hidden field.
When the view only has dropdownlists it works as expected.
Any idea how to overcome this.
Thanks again
David
KR
Keerthana Rajendran
Syncfusion Team
May 22, 2017 04:27 PM UTC
Hi David,
This issue occurs because ignore: [] is given as an empty array. We suggest you to pass the selector of DropDownList inside ignore:[$(“#id”)] when you use DropDownList along with some other input controls in the form.
Regards,
Keerthana.
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
DS dsapo
- May 16, 2017 07:23 PM UTC
- May 22, 2017 04:27 PM UTC