0

Trying to get a cursor to appear in one field in my Gravity Form. This is my Javascript, but it's not working:

<script type="text/javascript">
jQuery(document).ready(function($) { jQuery('#input_22_1').focus(); });
</script>

I've double checked the input several times to make sure I had the correct one yet this isn't working. The page I'm trying to get it working on is here: http://tinyurl.com/h8muwvp and the field is the Name of Business field.

Petey
  • 64
  • 1
  • 10

1 Answers1

0

You have a syntax error in your Javascript. From the console:

Uncaught SyntaxError: Unexpected token <

custom_js.js:7

A more elegant solution would be to use the HTML autofocus attribute on the form field.

Kyle O
  • 1,348
  • 10
  • 12
  • 1
    A note that while the autofocus attribute is certainly a more elegant solution, it is not currently supported by gravity forms (That is, there is no good way through the UI to add it) - so you are likely to need to go ahead with a solution like yours (after you fix the error in `custom_js.js` preventing the rest of your scripts from executing). One way to make it (slightly) more elegant is to use a class - so you can add the class autofocus to that field in the form editor and target it like `$('.autofocus input').focus()`. That way your code is not beholden to the auto generated field ID. – Chris O'Kelly Dec 03 '15 at 06:58