JetFormBuilder Form ID: How to Add One Like Elementor Forms

In the block editor, the JetForm block's Advanced > HTML anchor field already sets the id of the <form> element (since JetFormBuilder 3.0.7), but only for that one placement. The JetForm widgets for Elementor and Bricks have no such field, so there is no equivalent of the Form ID field in Elementor Forms. Crocoblock publishes a short official PHP filter that gives every form, in every builder, a fixed id based on its post ID. Paste it into your child theme's functions.php or a code snippets plugin, and every form renders as <form id="jet-form-123" ...>, where 123 is the form's post ID.
You can then use that fixed ID to target one specific form from CSS, JavaScript, analytics or tag manager setups, or another plugin. This is useful on pages that hold several forms.
- Built-in options vs. the snippet
- Find your form's ID number
- Where to paste the code
- How the snippet works and how to test it
- Use the ID in CSS, JavaScript and analytics
- Optional: custom ID names per form
- Common problems
Built-in options vs. the snippet
The plugin, now called JetFormBuilder — Dynamic Blocks Form Builder, has added a few related options over time:
| Option | Added in | What to keep in mind |
|---|---|---|
| HTML Anchor on the JetForm block (Advanced panel) | 3.0.7 | Sets the id on the <form> element itself, but only for that block placement. When filled in, it replaces the snippet's ID. |
| Form ID control on the JetForm widget | 3.4.4 | Chooses which form the widget displays (a manual or dynamic form ID). It does not add an HTML id. |
| Crocoblock's PHP filter | Official Code Lab snippet | Puts id="jet-form-{form_id}" directly on the <form> element for every form, using one consistent pattern. |
Every JetFormBuilder form also renders data-form-id="123" on the <form> tag, so selectors such as form[data-form-id="123"] work without code. Use the snippet when a tool needs a real id attribute.
Why the target element matters: many tracking tools and scripts look for the id of the <form> element itself. An ID on a wrapper div, such as the CSS ID in Elementor's Advanced tab, will not match those rules. The snippet hooks into JetFormBuilder's own form rendering, so you set it up once instead of configuring every placement. Use it when you need a dependable ID on the form tag.
Find your form's ID number
The ID the snippet uses is the form's WordPress post ID. To find it:
- In the WordPress admin, open the form you want to target for editing.
- Look at the browser address bar. It contains something like
post.php?post=123&action=edit. - The number after
post=is your form ID. Here, the form will render asid="jet-form-123".
The ID is stable. It stays the same when you edit the form or embed it on other pages. It only changes if you duplicate the form or import it into another site, because that creates a new post with a new ID.
Where to paste the code
Many people get stuck here, so pick one of these two options. Do not use both, or the filter runs twice.
Option A: child theme functions.php
- Back up your site first. A typo in
functions.phpcan take the site down. - Go to WordPress Dashboard > Appearance > Theme File Editor (Tools > Theme File Editor if you use a block theme).
- Make sure your active child theme is selected, then open
functions.php. - Paste the code below the existing code. Do not add another opening
<?phptag, because the file already has one. - Click Update File.
Use a child theme, not the parent theme. Parent theme updates overwrite functions.php, and your snippet would disappear. If Theme File Editor is missing, your host has probably disabled file editing. In that case, edit the file over SFTP or use Option B.
Option B: a code snippets plugin
- In your code snippets plugin, add a new PHP snippet.
- Paste the code without the
<?phptag. - Set it to run on the front end or everywhere, then save and activate it.
This option survives theme changes and is easy to switch off while you troubleshoot.
This is Crocoblock's official snippet. Add it to your child theme's functions.php or your snippets plugin:
Code
// Add a fixed id="jet-form-{form_id}" to every JetFormBuilder <form> element.
add_filter( 'jet-form-builder/before-start-form', function ( $before_form_start, $form ) {
$form->add_attribute( 'id', 'jet-form-' . $form->form_id );
return $before_form_start;
}, 0, 2 );How the snippet works and how to test it
jet-form-builder/before-start-formis a JetFormBuilder filter that runs just before the opening<form>tag is rendered.- The callback receives two arguments.
$before_form_startholds the markup output before the form.$formis the form object being rendered. $form->add_attribute( 'id', ... )adds theidattribute to the form tag.$form->form_idis the form's post ID, so the result isjet-form-123.return $before_form_start;passes the original markup back unchanged. If you remove this line, the markup before the form start is lost.0, 2sets priority 0, so it runs early, and 2 accepted arguments. Without the2, WordPress passes only the first argument, and PHP stops with a fatal 'Too few arguments' error because the function requires$form.
The code comes from Crocoblock's Code Lab and the matching gist.
Test it
- Clear your page cache and any caching or optimization plugin cache.
- Open a page that contains the form, right-click the form and choose Inspect.
- Find the form tag. You should see
<form id="jet-form-123" ...>with your form's number. - For a quick JavaScript check, run
document.getElementById('jet-form-123')in the browser console. It should return the form element, notnull.
You built the form in Gutenberg, Elementor or Bricks? Run this same check on the live page for each placement you rely on.
Use the ID in CSS, JavaScript and analytics
CSS
Style one form without affecting the others on the same page. You can add this in Appearance > Customize > Additional CSS or in your child theme stylesheet:
#jet-form-123 {
max-width: 640px;
margin: 0 auto;
}
#jet-form-123 input[type="email"] {
border-color: #0f766e;
}For more styling ideas, see our guide to styling JetFormBuilder file upload fields.
JavaScript
Attach behavior to one specific form. This example runs once, the first time a visitor starts interacting with the form:
document.addEventListener( 'DOMContentLoaded', function () {
const form = document.getElementById( 'jet-form-123' );
if ( ! form ) {
return;
}
form.addEventListener( 'focusin', function () {
console.log( 'Visitor started the contact form' );
}, { once: true } );
} );If you want to change what happens after a submission, our tip on a custom JetFormBuilder success message popup is a good next step.
Analytics and third-party tools
Tag managers and tracking tools can usually filter by form ID. Set the condition to match jet-form-123 so a tag or event fires only for that form, not for every form on the site.
Optional: custom ID names per form
You may want readable IDs such as contact-form, for example to match an existing Elementor tracking setup. Map form IDs to names and keep the default pattern for everything else. Use this instead of the snippet above, not alongside it:
add_filter( 'jet-form-builder/before-start-form', function ( $before_form_start, $form ) {
// Form post ID => HTML id you want on the <form> element.
$bmc_custom_ids = array(
123 => 'contact-form',
456 => 'quote-form',
);
$bmc_form_id = (int) $form->form_id;
if ( isset( $bmc_custom_ids[ $bmc_form_id ] ) ) {
$form->add_attribute( 'id', sanitize_html_class( $bmc_custom_ids[ $bmc_form_id ] ) );
} else {
$form->add_attribute( 'id', 'jet-form-' . $bmc_form_id );
}
return $before_form_start;
}, 0, 2 );Replace 123 and 456 with your real form IDs. Keep each name unique across the page.
Common problems
The id does not appear
- Clear every cache layer: page cache, CDN and any plugin that combines or caches HTML.
- Confirm the snippet is active. Check that it is in the active child theme's
functions.php, or that the snippet is switched on in your snippets plugin. - Make sure you are inspecting the
<form>tag, not a wrapperdivaround it.
The same form appears twice on one page
Both copies get the same id. That is invalid HTML. getElementById() returns only the first copy, and ID-based tracking may fire for the wrong one. Use a separate form for the second placement, or target the forms with an additional CSS class instead of the ID.
Critical error after saving functions.php
This is usually a stray second <?php tag, a missing semicolon or a half-copied line. Restore your backup, or fix the file over SFTP. Then paste the snippet again exactly as shown.
The form shows a different ID
If the JetForm block has a value in Advanced > HTML anchor, JetFormBuilder applies it after the snippet runs, so the anchor replaces jet-form-123. Clear the anchor field, or target the anchor ID instead.
The ID changed after moving the site
Importing forms into another site creates new post IDs. Look up the new form ID and update any CSS, JavaScript or tracking rules that use the old one.
Keep the plugin updated
As of October 2026, the current JetFormBuilder release is 3.6.7, and it requires WordPress 6.1+ and PHP 7.0+. Versions 3.6.5.2 through 3.6.6.1 include a series of security fixes, so run at least 3.6.6.1 before you build anything on top of your forms.
Once the snippet is in place, every JetFormBuilder form gets a predictable jet-form-{id} attribute that works the same way Elementor's Form ID does for styling, scripts and tracking. If you would rather have someone set up the IDs, tracking or custom form behavior for you, post a request on BoostMyCroco.
Frequently Asked Questions
Does JetFormBuilder have a form ID setting like Elementor Forms?
Where do I paste the JetFormBuilder form ID snippet?
Will the JetFormBuilder form ID change when I edit the form?
Does the snippet work with Elementor, Bricks and the Block Editor?
Why does getElementById return the wrong form or null?
Sources
- JetFormBuilder — Dynamic Blocks Form Builder (wordpress.org)
- Add Unique ID Attribute to JetFormBuilder Forms (crocoblock.com)
- JetFormBuilder Add id attribute to form · GitHub (gist.github.com)
- JetForm Overview — JetFormBuilder (jetformbuilder.com)
- GitHub - Crocoblock/jetformbuilder · GitHub (github.com)


