Hi,
I m currently using kendo MVVM framework and I want to use the validation feature provided by kendo.
I'm facing problem with validation when am displaying controls on a kendo window. here is the link to jsfiddle sample - http://jsfiddle.net/saisworld/UquQ6/6/
It works for the item row in the table and for other rows it doesn't. Even after clicking the button Validate it doesn't show the validation message.
Please advise.
Thanks
Sai
I m currently using kendo MVVM framework and I want to use the validation feature provided by kendo.
I'm facing problem with validation when am displaying controls on a kendo window. here is the link to jsfiddle sample - http://jsfiddle.net/saisworld/UquQ6/6/
It works for the item row in the table and for other rows it doesn't. Even after clicking the button Validate it doesn't show the validation message.
Please advise.
Thanks
Sai
5 Answers, 1 is accepted
0
Accepted
Hi Sai,
The problem occurs because inputs does not have a name attribute. To avoid it, please make sure that each input has a unique name. For example, you can use the record's ID :
For your convenience I updated the jsFiddle sample:
Regards,
Alexander Valchev
Telerik
The problem occurs because inputs does not have a name attribute. To avoid it, please make sure that each input has a unique name. For example, you can use the record's ID :
<
script
id
=
"tbl-Sales-editTemplate"
type
=
"text/x-kendo-template"
>
<
tr
>
<
td
data-bind
=
"text:ID"
></
td
>
<
td
><
input
type
=
"text"
name
=
"input#:ID#"
data-bind
=
"value:CompanyName, attr: {validationMessage: CompanyNameValidationMsg}"
required /> </
td
>
<
td
data-bind
=
"text:LengthOfContract"
></
td
>
<
td
data-bind
=
"text:Status"
></
td
>
</
tr
>
</
script
>
For your convenience I updated the jsFiddle sample:
Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sai
Top achievements
Rank 1
answered on 12 Aug 2013, 01:15 PM
Thanks Alexander. that worked.
I have one more query on the similar topic. Even though the validation message is displayed correctly for all the fields, the underlying view Model is getting updated as soon as we delete text from the text box. Is there a way to force it to check for validity before updating the underlying viewmodel?
Thanks
Sai
I have one more query on the similar topic. Even though the validation message is displayed correctly for all the fields, the underlying view Model is getting updated as soon as we delete text from the text box. Is there a way to force it to check for validity before updating the underlying viewmodel?
Thanks
Sai
0
Accepted
Hello Sai,
You may use the set event of the observable object:
Regards,
Alexander Valchev
Telerik
You may use the set event of the observable object:
For your convenience I updated the jsFiddle sample:
Relevant code is:
salesVM.bind(
"set"
,
function
(e) {
if
(!
this
.parent().parent().Isvalid()) {
//check validity
e.preventDefault();
//cancel viewmodel update
}
});
Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sai
Top achievements
Rank 1
answered on 15 Aug 2013, 10:12 AM
This is completely stopping from updating the underlying viewModel even though validation condition passes.
I have update the JsFiddle - http://jsfiddle.net/saisworld/UquQ6/11/
I have update the JsFiddle - http://jsfiddle.net/saisworld/UquQ6/11/
0
Hello Sai,
The if condition that I used to check the validity seems to be wrong for which I apologize. Please try the following:
For your convenience I updated the jsFiddle sample:
Regards,
Alexander Valchev
Telerik
The if condition that I used to check the validity seems to be wrong for which I apologize. Please try the following:
salesVM.bind(
"set"
,
function
(e) {
if
(!e.value) {
e.preventDefault();
}
});
For your convenience I updated the jsFiddle sample:
Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!