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

set focus after validation

1 Answer 14 Views
Rating
This is a migrated thread and some comments may be shown as answers.
Fit2Page
Top achievements
Rank 1
Iron
Veteran
Iron
Fit2Page asked on 24 Aug 2015, 02:36 PM

How could I set focus on the Radrating after client-side validation like:

 

http://docs.telerik.com/devtools/aspnet-ajax/controls/rating/how-to/radrating-with-customvalidatorplease help.

 

Marc

1 Answer, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 27 Aug 2015, 11:10 AM
Hi,

If you want to focus RadRating when you use it in combination with a CustomValidator, for example if the validation fails, you can try the following approach:
  1. Set the TabIndex property of the rating control so that it can be focused:
    <telerik:RadRating ID="RadRating1" runat="server" TabIndex="1">
    </telerik:RadRating>
  2. Modify the body of the ValidateRating handler in order to include retrieving of the HTML element of the rating and focusing it. The following example shows how to do so when the validation fails:
    function ValidateRating(source, args) {
        args.IsValid = (args.Value > 0);
        if (!args.IsValid) {
            $find("<%=RadRating1.ClientID %>").get_element().focus();
        }
    }


Regards,
Slav
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Rating
Asked by
Fit2Page
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Slav
Telerik team
Share this question
or