Set first form field as focused

I need to set the first field in my form as focused so when the form loads, it is able to take data from a barcode reader. Any thoughts on the best way to do this?

Thanks!

Hi Paul,

Dario, from Gravity Wiz here. This code should do the trick:

$( '#gform_GFFORMID' ).find( 'input:visible' ).first().focus();

You can add it to your form using our free Javascript plugin: Gravity Forms Custom Javascript - Free Plugin by Gravity Wiz

We would love to hear more about how are you using the barcode reader!

Best,

2 Likes

Hey Dario
Thanks for the quick reply! I have put this code in the form using the gravity wiz plugin, but it doesn’t seem to be doing anything. I assume that I need to specify which field ID needs to be set as the focused field, but I don’t know how to do that.

For the barcode reading function, barcode, qr code, rfid, etc, basically anything that has an HID profile can be used to begin a function chain to make a form perform a task. The catch for automation is that you have to be able to have the barcode reader input the text string into the correct field automatically on the form.

1 Like

Hi Paul,

It seems to be working for me locally without adding any specific field ID.

You can reach us out directly here: Have a question about Gravity Perks? - Gravity Wiz

We would love to know more about your use case!

Cheers,

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.