Change order of showing error message and focusing element

Show alert with error message sooner than setting focus on element. In firefox element lost focus when alert is invoked.