Open and set the focus on a specific element via URL


Is there a way to set the focus / cursor directly on a specific field when opening a form via a URL?


Dear @bigmad,
Sure, we have an example on how to populate fields from a link - Populate form with data from different sources with JavaScript (public forms) — Public web forms

Same can be done with the focus, though the following code will only work for some fields which have an input to focus on:
window.$ = $;

    var queryString =;
    var urlParams = new URLSearchParams(queryString);

Dear Nikita, Thanks for your answer. I need the function for guiding my users to find the right field in a form. But, unfortunately the field is empty at the beginning.
If I understand right, then your code works by finding a specific input.


Dear @bigmad,
It works by finding the input of specific field, specified in the URL. Some fields have input, others do not, so it wouldn't work for all field types, but it works well:

Let me know the field types you're working with, we can help adjust the code.

This code above also looks for specific field in the URL params, but if you know what the field is and don't need to get it from URL, you can simply place field name in the code:

    //focus and move to Title field