ValidationSummary properties usint KendoValidator

3 posts, 0 answers
  1. Ant
    Ant avatar
    18 posts
    Member since:
    Dec 2013

    Posted 31 May 2014 Link to this post

    Hi,

    I have a rather large form which is spread over a series of tabs to break it down into sections. I have a single "Save" button that uses ajax to post the form. This all works fine, and the validator shows errors next to the controls that fail validation. The issue i have is that if i try and save something on one tab it isn't immediately clear which tab might be showing a control that fails validation, and therefore isn't clear to the user why the form hasn't submitted.

    What i'd like to do is use the validationsummary or a simple div to display the errors above the tabs in a list form. I've been experimenting with the KendoValidator and can see the list or errors under validator._errors. but is it possible to access the _errors values to append to a div using a foreach on validator_errors?

    Thanks

    Ant
  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 31 May 2014 Link to this post

    Hello Ant,

    The errors can be retrieved via the errors method. Similar to the following:

    <form>
          <!-- form content-->
    </form>
     
    <ul id="errors"></ul>
     
    <script>
        $(document).ready(function() {
            $("form").kendoValidator({
                validate: function() {
                    showErrors(this.errors());
                }
            });
        });
     
        function showErrors(errors) {               
            var errorsContainer = $("#errors");
            var html = "";
     
            for (var idx = 0; idx < errors.length; idx++) {
                html += "<li>" + errors[idx] + "</li>";
            }
            errorsContainer.empty().append($(html));
        }
    </script>


    Regards,
    Rosen
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Ant
    Ant avatar
    18 posts
    Member since:
    Dec 2013

    Posted 02 Jun 2014 in reply to Rosen Link to this post

    Thank you Rosen, that's exactly what I was after
Back to Top