Bug in validation without data-role

7 posts, 0 answers
  1. Nick
    Nick avatar
    31 posts
    Member since:
    Oct 2011

    Posted 01 May 2012 Link to this post

    I don't fully understand why this is happening but it appears to be a bug.  Pardon not having full source code, I don't have time to extract the useful parts into a jsfiddle at the moment.

    Essentially I have MVVM binding to a remote data source.

    <input type="text" id="jobName" data-bind="value: data.Name" class="k-input validate" required />
     
    var validatable = $("#windowUpdateJob").find("#jobName").kendoValidator().data("kendoValidator");

    When I initialize the validator, it seems to break the jobName object.  Various things cause the following error:

    kendo.all.js ~line # 7130 - this.widget.value is not a function

    Without the validator it works ok.

    I also found that if I just add a data-role to the <input> it also fixes the issue.  i.e.

    <input type="text" data-role="NumericTextBox" id="jobName" data-bind="value: data.Name" class="k-input validate" required />


    Maybe I'm doing something funky somewhere else in the code that's causing this?  I don't have a problem adding a data-role to all MVVM objects, but in this case jobName is not numeric - that's just the quickest thing I found that worked.
  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 03 May 2012 Link to this post

    Hello Nick,

    The behavior you are experiencing is due to the fact that a kendoValidator is instantiated over a element which has value binding defined. This will instruct the MVVM that this element is a widget and a widget value binding should be applied. However, in this case the value binding is not valid as the widget is kendoValidator which does not support value. In order to workaround this limitation you should instantiate the kendoValidator over  the container element of the input instead.

    Greetings,
    Rosen
    the Telerik team
    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. Nick
    Nick avatar
    31 posts
    Member since:
    Oct 2011

    Posted 03 May 2012 Link to this post

    I see.  The problem with this was that when I ran the validator on the container of all of my form elements, the validation would work, but the error messages would show up and then immediately disappear.  Have you seen this before or do I need to put together a jsfiddle to troubleshoot?
  5. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 04 May 2012 Link to this post

    Hello Nick,

    I'm afraid that I'm not aware of such behavior. Thus, it will be appreciated if you  could provide a simple jsFiddle test page which exhibits the mentioned issue. 

    All the best,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Carlos
    Carlos avatar
    1 posts
    Member since:
    Dec 2012

    Posted 18 Jan 2013 Link to this post

    Hello,

    I'm having the same problem as described by Nick.

    Here is a fiddle to demonstrate.  Validation only triggers if you enter something and then clear it, but then it dissappears the moment you release the save button.

    Fiddle example

    Carlos
  7. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 21 Jan 2013 Link to this post

    Hello Carlos,

    In order for Kendo Validator to function correctly, the input elements which requires validation should have valid name attributes set. Thus, please add such attributes and see if there is changed in the observed behavior.

    Greetings,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  8. Zachary
    Zachary avatar
    23 posts
    Member since:
    Feb 2013

    Posted 01 May 2013 Link to this post

    Rosen,

    I found this forum post because my issue was with validators showing up next to the wrong input field. Your comment about adding name attributes was the solution. I notice the jsFiddle posted above experiences the same problem I was having. I added name attributes in the jsFiddle and my project and the problem went away in both cases.

    Bottom line is that this should be proclaimed far and wide: All Kendo UI validation targets should have a unique name attribute.

    Thanks,
    Zachary
Back to Top
Kendo UI is VS 2017 Ready