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

How to prevent firing custom validation function multiple times

3 Answers 435 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 13 Jul 2016, 05:40 AM

Hi,

I have use custom validation function to my grid, it's fired twice every time. How to prevent this?

3 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 14 Jul 2016, 03:03 PM
Hi Michael,

The validation will fire twice, because it is triggered once by the blur event of the input element and once when the Grid tries to close the cell for incell edit mode or when the Update button is clicked. As discussed in the forum thread below, this behavior could not be changed:

Best Regards,
Konstantin Dikov
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Ethan
Top achievements
Rank 1
answered on 24 Mar 2020, 10:38 AM
How come it fires twice for pop-up edit aswell in grid.This is cause xss vulnerabilities when a html tag with a script and onerror is used with the custom validator (kk</script><img src=1 onerror='alert(223)'/>)
0
Tsvetomir
Telerik team
answered on 26 Mar 2020, 07:50 AM

Hi Ethan,

Indeed, the behavior is clearly observed when the Kendo UI Grid is utilizing the PopUp edit mode. In short, the validation is triggered twice - once when the cell is blurred so that if any change is needed, the user is prompted immediately. And once when the Update button is clicked - this is needed to validate the fields that have not been changed and for which the validation of blur has not been triggered. 

As an alternative approach, you could remove the custom validation from the validation configuration of the field and execute it within the Save event handler, manually.

 

Regards,
Tsvetomir
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Ethan
Top achievements
Rank 1
Tsvetomir
Telerik team
Share this question
or