Tag Helpers and Model Validation

2 posts, 0 answers
  1. Brian
    Brian avatar
    45 posts
    Member since:
    Aug 2013

    Posted 26 Jul 2018 Link to this post

    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!

  2. Dimitar
    Admin
    Dimitar avatar
    814 posts

    Posted 31 Jul 2018 Link to this post

    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.
Back to Top