When my form load I would like to set the focus on the first field in the form. I know I can use jquery to do this by doing $('inout id').focus();
. Where would I put this code so that it only runs on a certain form?
Is there a simpler way?
Updated
Using a mixture of smile's answer and clive's comment the code that got it working in the end was:
$form['#attached']['js'] = array('(function ($){$(document).ready(function() { $(".form-item-field-name input").focus()});})(jQuery);' => array( 'type' => 'inline'));