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

Bug in validation without data-role

6 Answers 251 Views
Validation
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 01 May 2012, 11:41 PM
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.

6 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 03 May 2012, 12:24 PM
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!
0
Jeff
Top achievements
Rank 1
answered on 03 May 2012, 05:09 PM
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?
0
Rosen
Telerik team
answered on 04 May 2012, 01:09 PM
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!
0
Carlos
Top achievements
Rank 1
answered on 19 Jan 2013, 02:52 AM
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
0
Rosen
Telerik team
answered on 21 Jan 2013, 11:43 AM
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!
0
Zachary
Top achievements
Rank 1
answered on 01 May 2013, 08:20 PM
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
Tags
Validation
Asked by
Jeff
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Jeff
Top achievements
Rank 1
Carlos
Top achievements
Rank 1
Zachary
Top achievements
Rank 1
Share this question
or