Use this file to discover all available pages before exploring further.
The OpnForm JavaScript SDK enables you to programmatically control embedded forms, listen to events, and build dynamic integrations. It includes automatic iframe resizing and full backward compatibility with existing embeds.
// Listen to form submissionopnform.on("submit", function (data) { console.log("Form submitted!", data); console.log("Submission data:", data.data);});// Set a field valueopnform.get("my-form").setField("email", "user@example.com");// Toggle dark modeopnform.get("my-form").toggleDarkMode();
// Remove specific handlerconst handler = (data) => console.log(data);opnform.on("submit", handler);opnform.off("submit", handler);// Remove all listeners for an eventopnform.off("submit");
opnform.get("my-form").setField("email", "user@example.com");opnform.get("my-form").setField("name", "John Doe");// Works for hidden fields tooopnform.get("my-form").setField("utm_source", "google");
// Check if a field has an errorconst hasError = opnform.get("my-form").hasError("email");// Get error message for a fieldconst errorMsg = opnform.get("my-form").getError("email");// Get all errorsconst errors = opnform.get("my-form").getErrors();// { email: "Invalid email format", phone: "Required" }
// Toggle dark modeopnform.get("my-form").toggleDarkMode();// Set specific modeopnform.get("my-form").setDarkMode(true); // Darkopnform.get("my-form").setDarkMode(false); // Lightopnform.get("my-form").setDarkMode("auto"); // Follow system// Check current modeconst isDark = opnform.get("my-form").isDarkMode();
// Submit form programmaticallyopnform.get("my-form").submit();// Reset form to initial stateopnform.get("my-form").reset();// Focus on first error fieldopnform.get("my-form").focusFirstError();
// Open popupopnform.get("my-form").open();// Close popupopnform.get("my-form").close();// Toggle popupopnform.get("my-form").toggle();// Check if openconst isOpen = opnform.get("my-form").isOpen();
// Get a specific form instanceconst form = opnform.get("my-form-slug");// Get all forms on the pageconst forms = opnform.getAll();// Check if a form is readyconst isReady = opnform.isReady("my-form-slug");
Existing embeds using initEmbed() continue to work without changes. The
SDK provides full backward compatibility.
<!-- Old embed code still works --><iframe id="my-form" src="https://opnform.com/forms/my-form"></iframe><script src="https://opnform.com/widgets/iframe.min.js"></script><script> initEmbed("my-form", { autoResize: true });</script>
We recommend upgrading to the new SDK to access event callbacks and
programmatic control features.