Auto-Focus on Form Fields | Community
Skip to main content
May 23, 2013
Question

Auto-Focus on Form Fields

  • May 23, 2013
  • 3 replies
  • 1274 views
Is there a way to code my Marketo form/landing page such that the first form field in the form is clicked/in-focus? IE if the user were to just start typing once the form loads, the text would be entered into the input field of question 1 on the form.
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

May 23, 2013
you can definitely do it with javascript - here's a bit of discussion around whether you should/should not do this.
http://ux.stackexchange.com/questions/5755/auto-focus-on-the-first-form-field-done-right


the answer in there probably won't work because you have to modify the body tag. but you can try using the jQuery solution documented here:
http://stackoverflow.com/questions/277544/how-to-set-the-focus-to-the-first-input-element-in-an-html-form-independent-from

this i believe you can throw into some script tags and use an html placeholder.
May 23, 2013
Either incorporate into the code of the landing page template or just drag in an HTML block and try this:

<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script>
$(document).ready(function() {
    $('form:first *:input[type!=hidden]:first').focus();
});


May 23, 2013
Hey Ashley...great minds think alike. You beat me to it by seconds. Well played :)