MVC unobtrusive validation doesn't work

5 posts, 0 answers
  1. Andrii
    Andrii avatar
    13 posts
    Member since:
    Nov 2011

    Posted 29 May 2013 Link to this post

    Hi! We are using in project Jquery Unobtrusive validation, but with kendo Dropdownlist validation doesn't work on client.

    @(Html.Kendo().ComboBoxFor(model => model.CountryId)
          .Filter(FilterType.Contains)
          .BindTo(ViewBag.Countries)
          .HtmlAttributes(CommonHelpers.MergeHtmlAttributes(Html.GetUnobtrusiveValidationAttributes(
              CommonHelpers.GetPropertyName(() => Model.CountryId)),
              new Dictionary<string, object>(){
                              { "class", "combobox-country" }})))


    How to fix this issue? Is it possible to combine Kendo Combobox and client-side mvc unobtrusive jquery validation?
    Thanks!
  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 31 May 2013 Link to this post

    Hello,

    A problem with the jQuery validation and the dropdownlist could occur if you are using jquery.validate 1.9+. By default it ignores hidden inputs and the dropdownlist uses one to hold the value. In order to enable the validation in this case you should override the validator default settings e.g.

    $.validator.setDefaults({ ignore: '' });
    Regards,
    Daniel
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Andrii
    Andrii avatar
    13 posts
    Member since:
    Nov 2011

    Posted 06 Jun 2013 Link to this post

    Thanks! And now doesn't work only cascade controls (dropdowns, comboboxes) - when they are disabled((((
    Do you know how to fix it?
    Thanks!
  5. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 07 Jun 2013 Link to this post

    Hello Andrii,

    Disabled inputs should not be validated and there is no option that could be used to enable the validation.

    Regards,
    Daniel
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Andrii
    Andrii avatar
    13 posts
    Member since:
    Nov 2011

    Posted 07 Jun 2013 Link to this post

    Hmm.. guys, i'm confused. Because Kendo UI controls i can't validate, always i must to write "shit"  in my code.
Back to Top
UI for ASP.NET MVC is VS 2017 Ready