How to Autofocus the Email Field on a Lightbox

Follow these steps to autofocus the email field, or make the cursor automatically default to the email field, when your lightbox is launched.

Step 1: Custom JavaScript

Log into Digioh, and click your name in the upper-right corner. Select “Custom JavaScript (Boxes)” from the dropdown.

custom box javascript

Step 2: Add New Custom JavaScript

On the next page, click the Add New Custom JavaScript Snippet button. Set the event trigger for your new snippet to ” After Display”.
add new javascript snippet

Step 3: Paste JavaScript Snippet

Paste this code into the box:

form_input_email.focus()

Step 4: Enter Your Lightbox ID

Make sure you enter a box ID, or box IDs to apply the JavaScript to. In the Include / Exclude section, enter “return true;” then save it and turn it on. It should look like this:

enter lightbox id to enable autofocus on selected lightbox

And that’s all there is to it! The cursor will be in the email field by default when your lightbox launches.

If you need help setting this up, send us an email, and we’ll get you up and running in no time!

Related Reading:

Tagged: