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

k-invalid-msg not working properly

1 Answer 166 Views
This is a migrated thread and some comments may be shown as answers.
Emil
Top achievements
Rank 1
Emil asked on 19 Oct 2016, 02:03 PM

Here is an example which demonstrates the issue I am having. http://dojo.telerik.com/EcEgo

To reproduce the issue, delete the value in the numeric text box and than click validate button. You should see the error message in the <span data-for="UnitPrice" class="k-invalid-msg"></span> which is defined by me in the DOM. After than click inside the numeric text box (focus) and then click outside the numeric text box to lose focus. You'll see 2nd validation message to appear.

 

My question is - why this happens? Am I doing something wrong or this is a defect in NumericTextBox?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 20 Oct 2016, 11:48 AM
Hello Emil,

The second undesired message appears because the NumericTextBox is actually made from two input elements. One when the input is focused and one when it is not. In this scenario, both inputs are validated and this creates the undesired effect:

http://docs.telerik.com/kendo-ui/controls/editors/numerictextbox/overview#initialize-the-numerictextbox

I modified the example to work as expected:

http://dojo.telerik.com/UdOlO

Also, please have in mind that initializing the Validator on every click of the button is not recommended as this will create a widget every time the button is clicked:

http://docs.telerik.com/kendo-ui/intro/installation/jquery-initialization#duplicate-initialization

I hope this is helpful.

Regards,
Stefan
Telerik by Progress
 
Build rich, delightful, *native* Angular 2 apps with Kendo UI for Angular 2. Try it out today! Kendo UI for Angular 2 (currently in beta) is a jQuery-free toolset, written in TypeScript, designed from the ground up to offer true, native Angular 2 components.
 
Asked by
Emil
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or