Set focus on phone number field when validations fails




I have a text field set up as a phone number field, with the following in the change event to accept numbers only:


xfa.event.change = "";


In the Pattern validation, I have this mask on all tabs (Display, Edit, Validation and Data):

text{'('999')' 999-9999}

I want the user to be able to just enter numbers and have the parentheses and dash added automatically ["(123)-456-7890"].

How do I get the focus to stay on this field when it fails validation? (e.g., insufficient or too many digits).  I have looked into validationState but couldn't figure out how to use it (I'm a noob javascripter).

Thanks for any help.