validate callback doesn't work

Thread is closed for posting
4 posts, 0 answers
  1. Jaime
    Jaime avatar
    60 posts
    Member since:
    Mar 2013

    Posted 10 May 2014 Link to this post

    This is straight forward but the callback is never hit. 

            $("#form1").kendoValidator({
                validate: function(e) {
                    debugger
                    console.log("valid" + e.valid);
                }
            }).validate();

    Can anybody help me on this (Yes the form exists)?
    Also, shouldn't this also be hit on blur?  
  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 13 May 2014 Link to this post

    Hi Jaime,

    As you may know the validate is method of the kendoValidator widget. However in the snippet you have pasted it is called on the actual form element. This is what is return by the jQuery plugin creator method (kendoValidator())
    Therefore, in order to execute the validate method you will need to get the widget instance first, similar to the following:

    $("#form1").kendoValidator({
      validate: function(e) {
        debugger
        console.log("valid" + e.valid);
      }
    }).data("kendoValidator").validate();


    Regards,
    Rosen
    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
  4. ken
    ken avatar
    3 posts
    Member since:
    Aug 2013

    Posted 16 Mar in reply to Rosen Link to this post

    It is surprising that the validate function is not called on blur. This appears to make it impossible to disable buttons while invalid. Unfortunately, <button data-bind="disabled: field"> doesn't work though <input type="submit" data-bind="disabled: field"> does work.

    I tried hacking this by calling validate() in a timer. The problem is the error msgs appear before the inputs have been dirtied.

    Another issue is that Model inherits from Observable but binding a Model instance to a form causes exceptions. 

    Another issue is I don't see a Model.validate() method or a way to bind a Model instance.

    Is there a way to change tooltip position in the errorTemplate?

  5. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 18 Mar Link to this post

    Hello ken,

    I'm not sure I have understood the context of your question nor how it is related to the original thread's topic. Therefore, please open a separate support request in which to provide as much details as possible(a small sample will be appreciated) about the problem you are facing.

    Regards,
    Rosen
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready