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

Compare validator

1 Answer 401 Views
Validation
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 30 Jun 2014, 12:57 PM
Trouble getting compare validator working

 

Have a grid (mvc, razor) with popup editing. 2
password fields that should compare. On the model I’ve data annotated:
[DataType(DataType.Password)]
[Compare("Password")]


 

How to get validation working?


I have implemeted a solution found else where on your forum - it's working but not pretty:


.Events(events => events.Error("grid_error"))

<script>
    
function grid_error(e) {
        
if (e.errors) {
            
var message = "There are some errors:\n";
            
// Create a message containing all errors.
            $.each(e.errors, function (key, value) {
                if ('errors' in value) {
                    $.each(value.errors, function () {
                        message += this + "\n";
                    });
                }
            });
            // Display the message
            alert(message);
            // Cancel the changes
            var grid = $("#grid").data("kendoGrid");
            grid.cancelChanges();
        }
    }
</script>

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 02 Jul 2014, 06:49 AM
Hi Michael,

I would suggest to check the following forum post where my colleague Daniel already provided example solution for supporting this attribute:

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Validation
Asked by
Michael
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or