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

ValidationSummary properties usint KendoValidator

2 Answers 308 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ant
Top achievements
Rank 1
Ant asked on 31 May 2014, 10:59 AM
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 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 31 May 2014, 02:57 PM
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.

 
0
Ant
Top achievements
Rank 1
answered on 02 Jun 2014, 07:34 AM
Thank you Rosen, that's exactly what I was after
Tags
General Discussions
Asked by
Ant
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Ant
Top achievements
Rank 1
Share this question
or