src code

class method Form.focusFirstElement

Form.focusFirstElement(form) → Element

Gives keyboard focus to the first element of the form. Returns the form.

Uses Form.findFirstElement to get the first element and calls Form.Element.activate on it. This is useful for enhancing usability on your site by bringing focus on page load to forms such as search forms or contact forms where a user is ready to start typing right away.

This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.