How to set focus on a control in CRM 2011 using Javascript
Option 1:
var control = Xrm.Page.ui.controls.get("AttributeName");
control.setFocus();
Option 2:
In some situations we need to show the alert to end user and then set the focus on the field where validation takes place, in this case setting focus directly on that fails so simply set the focus to a different field on the same tab first and then reassign the focus to the field from which the OnChange() event was called like so:
Xrm.Page.getControl("AnyFieldFromSameTab").setFocus(true);
Xrm.Page.getControl("TheFieldYouReallyWantToFocus").setFocus(true);