Fix display error message

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