How to set the focus to a same widget in case a custom validation error fails?

Hello Everyone, I am creating a time report app. One time report can have multiple time report lines in order to capture the hours for all days in a week (list view and table containers) . In the on change event of each hours , i check if the sum total of hours entered is > 24. The validation message executes successfully, but the focus goes to the next widget (i.e. the immediate widget in case of TAB or any widget clicked using mouse). What I need is in case of an error, the cursor should be on the same widgets. Any Ideas?
1 answers

I actually had a co-worker do the same thing. he used an HTML Snippet on the page and set it for javascript with jquery. Then added the following code within the control. This code will find the alert.danger css class that is visible and is tied to the css selector widget we use for error handling on our controls. Then it looks inside the (wrapper of the page) and scrolls to the first error is sees. The bottom two numbers determine how quickly the screen scrolls to the control on the page. Hopefullyl this helps.

setTimeout(function() { var firstError = $(".alert-danger:visible").first();

$('').animate({ scrollTop: firstError.offset().top-350 }, 200); },250);