This is a migrated thread and some comments may be shown as answers.

Tag Helpers and Model Validation

1 Answer 374 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 2
Iron
Brian asked on 26 Jul 2018, 02:50 PM

Hi,

Is it possible to use tag helpers with model validation using Kendo's validation framework?

C#

[Required]
public string Title { get; set; }

 

HTML

<kendo-maskedtextbox for="Title"></kendo-maskedtextbox>
<span data-for="Title" class="k-invalid-msg"></span>

 

JS

var validator = $("#changeForm").data("kendoValidator");

validator.validate();

 

I can't seem to get the required validation to appear.  The form posts even if the control is blank.  Can anyone give me a working example of model validation with tag helpers in .NET Core?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 31 Jul 2018, 11:23 AM
Hello Brian,

In general, you are able to use the Kendo Validator to display model errors. This works successfully with the NumericTextBox, ComboBox, DropDownList and the rest of the widgets from the inputs group.

However, after further investigation, I can confirm that there is an issue with the MaskedTextBox TagHelper, which prevents the data-* attributes from being rendered on the generated input element. Thus, the validation messages are not displayed successfully. I have logged this as a bug in the official Kendo UI GitHub repository. You can start tracking the progress that we make on it from issue #4415.

As a workaround, you could either add the data-val and data-val-required attributes manually or use the HtmlHelper for rendering the widget. 

Also, as a small token of gratitude for helping us discover this issue, I have updated your Telerik Points accordingly.

Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
General Discussions
Asked by
Brian
Top achievements
Rank 2
Iron
Answers by
Dimitar
Telerik team
Share this question
or