Re: Auto-Focus on Form Fields

Anonymous
Not applicable

Auto-Focus on Form Fields

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.
Tags (1)
3 REPLIES 3
Anonymous
Not applicable

Re: Auto-Focus on Form Fields

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.
Anonymous
Not applicable

Re: Auto-Focus on Form Fields

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();
});
</script>

It'll automatically focus on the first field in your form.



Source: http://stackoverflow.com/questions/277544/how-to-set-the-focus-to-the-first-input-element-in-an-html...


Anonymous
Not applicable

Re: Auto-Focus on Form Fields

Hey Ashley...great minds think alike. You beat me to it by seconds. Well played 🙂