Compare validator

2 posts, 0 answers
  1. Michael
    Michael avatar
    8 posts
    Member since:
    Dec 2013

    Posted 30 Jun 2014 Link to this post

    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>
  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 02 Jul 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
Back to Top