APIs & Integrations

Not applicable

Hubspot forms missing id for some fields

SOLVE

Hi there,

Just wondering why hubspot has input ids for some inputs in hubspot fields but not others. These 2 fields are from the same form one text and one hidden. I'm using the tag manger to put data in the fields, and not having input IDs makes it really difficult.

Has ID

<input id="firstname-5251181d-c7a7-42b2-83dc-cf485f4c7307_6784" class="hs-input invalid error" name="firstname" required="" value="" placeholder="" autocomplete="given-name" data-reactid=".hbspt-forms-0.0:$0.1:$firstname.$firstname.0" type="text">

No ID
<input name="z_test_steve_temp" class="hs-input" value="not-ie" data-reactid=".hbspt-forms-0.0:$5.1:$z_test_steve_temp.$z_test_steve_temp.0" type="hidden">
0 Upvotes
1 Accepted solution
Solution
Not applicable

Hubspot forms missing id for some fields

SOLVE

Hi @Derek_Gervais,

Thanks for the clarification.

Here is a bit of code if anyone ends up here and is trying to fill in a hubspot form input that's a hidden field.
This would put the word 'test' in a field called 'your_field_name_here'.

<script>
document.getElementsByName('your_field_name_here')[0].value = 'test';
</script>

View solution in original post

4 Replies 4
Solution
Not applicable

Hubspot forms missing id for some fields

SOLVE

Hi @Derek_Gervais,

Thanks for the clarification.

Here is a bit of code if anyone ends up here and is trying to fill in a hubspot form input that's a hidden field.
This would put the word 'test' in a field called 'your_field_name_here'.

<script>
document.getElementsByName('your_field_name_here')[0].value = 'test';
</script>
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Hubspot forms missing id for some fields

SOLVE

Hi @steve,

Thanks for including that example. As it turns out, we don't include an id for hidden form fields; ids are only included for visible form fields. The ids are intended for use internally by the form embed code, and aren't needed for internal form fields. I'd recommend not depending on the id attribute, and instead using the name attributes. It may seem less ideal, but the name attribute is always going to be set to the internal property name, so it's a more general and consistent way to target the fields.

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Hubspot forms missing id for some fields

SOLVE

Hi @steve,

I'm actually not entirely sure what the expected behavior here is; can you post a link to a page that has a form like this on it? I'd like to investigate the form in question and do some testing so that I can better understand what's going on.

0 Upvotes
Not applicable

Hubspot forms missing id for some fields

SOLVE

Hi Derek,

Here is the page https://www.pfleet.com/landing/cfn

A simple example using the id with javascript
https://www.w3schools.com/tags/att_id.asp

You can use "name", but its not ideal, but just thought it was strange that some inputs have an id and some don't.

Hope that helps

0 Upvotes