Hi,
When a form loads we want to highlight which fields are required fields by changing the colour of the label. If you look at the attached image SoureRequiredAuthorNotRequired.PNG you can see the Source field is highlighted in red as it is a required field. When a value is entered for the Source the red highlighting disappears.
To do this we have used:
We have now added in a Kendo date picker and hoped this would work in the same way:
Unfortulately this does not work. It seems that to validate a kendo date picker you have to use the kendo validator. Is that correct?
Assuming that is correct, we added the following code:
to use the kendo validator. Looking at the documentation you have a validateInput function which validates just one field:
http://docs.telerik.com/kendo-ui/api/javascript/ui/validator#methods-validateInput
We then tried:
Which did not work. validateInput only seems to work if it used as part of a button click. Is this correct?
How can I get this to work so that the red highlighting appears when nothing has been entered and disappears when a value has been entered (without the user clicking on a save button etc)?
Many thanks
When a form loads we want to highlight which fields are required fields by changing the colour of the label. If you look at the attached image SoureRequiredAuthorNotRequired.PNG you can see the Source field is highlighted in red as it is a required field. When a value is entered for the Source the red highlighting disappears.
To do this we have used:
<
div
class
=
"form-group"
ng-class
=
"{'has-error' : editForm.Source.$error.required}"
>
<
label
for
=
"Source"
class
=
"control-label required"
>Source</
label
>
<
input
type
=
"text"
id
=
"Source"
name
=
"Source"
ng-model
=
"vm.data.record.source"
class
=
"form-control input"
required />
</
div
>
<
div
class
=
"form-group"
>
<
label
for
=
"Author"
class
=
"control-label"
>Author</
label
>
<
input
type
=
"text"
id
=
"Author"
name
=
"Author"
ng-model
=
"vm.data.record.author"
class
=
"form-control input"
/>
</
div
>
We have now added in a Kendo date picker and hoped this would work in the same way:
<
div
class
=
"form-group"
ng-class
=
"{'has-error' : editForm.PressCuttingDate.$error.required}"
>
<
label
for
=
"PressCuttingDate"
class
=
"control-label required"
>Date</
label
>
<
input
type
=
"date"
kendo-date-picker
id
=
"PressCuttingDate"
name
=
"PressCuttingDate"
k-ng-model
=
"vm.data.record.pressCuttingDate"
k-format
=
"'dd/MM/yyyy'"
style
=
"width: 100%"
required />
</
div
>
<
div
class
=
"form-group"
ng-class
=
"{'has-error' : editForm.Source.$error.required}"
>
<
label
for
=
"Source"
class
=
"control-label required"
>Source</
label
>
<
input
type
=
"text"
id
=
"Source"
name
=
"Source"
ng-model
=
"vm.data.record.source"
class
=
"form-control input"
required />
</
div
>
<
div
class
=
"form-group"
>
<
label
for
=
"Author"
class
=
"control-label"
>Author</
label
>
<
input
type
=
"text"
id
=
"Author"
name
=
"Author"
ng-model
=
"vm.data.record.author"
class
=
"form-control input"
/>
</
div
>
Unfortulately this does not work. It seems that to validate a kendo date picker you have to use the kendo validator. Is that correct?
Assuming that is correct, we added the following code:
<
form
name
=
"editForm"
novalidate
kendo-validator
=
"vm.formValidation"
>
to use the kendo validator. Looking at the documentation you have a validateInput function which validates just one field:
http://docs.telerik.com/kendo-ui/api/javascript/ui/validator#methods-validateInput
We then tried:
<
div
class
=
"form-group"
ng-class
=
"{'has-error' : vm.formValidation.validateInput($('input[name=PressCuttingDate]')) }"
>
<
label
for
=
"PressCuttingDate"
class
=
"control-label required"
>Date</
label
>
<
input
type
=
"date"
kendo-date-picker
id
=
"PressCuttingDate"
name
=
"PressCuttingDate"
k-ng-model
=
"vm.data.record.pressCuttingDate"
k-format
=
"'dd/MM/yyyy'"
style
=
"width: 100%"
required />
</
div
>
Which did not work. validateInput only seems to work if it used as part of a button click. Is this correct?
How can I get this to work so that the red highlighting appears when nothing has been entered and disappears when a value has been entered (without the user clicking on a save button etc)?
Many thanks