Validation provider keeps focus

1 Answer 262 Views
ValidationProvider
Martin Hamilton
Top achievements
Rank 1
Iron
Iron
Veteran
Martin Hamilton asked on 29 Jul 2021, 11:24 AM

It seems that after the Validation Provider kicks in on a control - and sets focus to it and displays the 'error' message....

That it keeps the focus on that control and the user cannot click on a different control on the form.

So, for example.

Let's say there are 2 radio buttons - each radio button causes a dropdown to load certain records

The user clicks on the Dropdown - then realizes they needed to click on the 2nd radio button first.

But now, the validation provider won't let them click the 2nd radio button because it maintains focus on the dropdown.

Is there a way to 'release' the focus so that the user can click on the 2nd radio button?

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 30 Jul 2021, 09:13 AM
Hello, Martin,

The purpose of RadValidationProvider is to ensure that a certain control has a valid value. Hence, when you focus a control to be validated and you try to leave this control, the validation is expected to be performed. That is why when you focus a RadDropDownList and click a RadRadioButton, the RadDropDownList control will lose focus and the validation logic will be performed. If the validation is not successful, the focus is kept in RadDropDownList.

RadValidationProvider offers the ValidationMode property. It controls when the validation will be performed. The available options are None, OnValidating, OnTextChange, Programmatically. Default values is OnValidating. You can change it to Programmatically.

An alternative solution is to keep the default behavior and handle the ControlValidation event which is fired when the validation fails. It gives you the possibility to provide conditional validation and control the situations in which the control being validated has correct content or not via the IsValid argument. A sample approach is demonstrated in the following article:
https://docs.telerik.com/devtools/winforms/controls/validation-provider/validation-rules#controlvalidation-event 
 
I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
ValidationProvider
Asked by
Martin Hamilton
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or