DEV Community

Explorer
Explorer

Posted on

🧩 Automate “Uncheck Sanitize Input” in Joget Builder using JavaScript

If you’ve ever worked in Joget Form Builder, you know how time-consuming it can be to manually uncheck the “Sanitize Input” property for every Text Field, Text Area, or Custom HTML element — especially when your form has dozens of them.

Here’s a quick automation snippet that saves you from repetitive clicking. You can run this directly in your browser console while editing a form in Joget.


🚀 Step-by-Step Guide

🧠 What this script does

This script automatically:

  1. Opens each Text Field, Text Area, or Custom HTML field.
  2. Unchecks the “Sanitize Input” checkbox.
  3. Clicks Apply to save the property.

All without you doing it manually — it just runs through every field one by one.


💻 Copy & Paste Code

Inspect your Joget form builder page and paste this script into the browser console:



<script>
  $('[data-cbuilder-label="Custom HTML"],[data-cbuilder-label= "Text Area"], [data-cbuilder-label="Text Field"]').each(function (index, el) {
    setTimeout(() => {
      // Step 1: Click the Text Field (open property editor)
      el.dispatchEvent(new MouseEvent("mousedown", { bubbles: true }));
      el.dispatchEvent(new MouseEvent("mouseup", { bubbles: true }));
      el.dispatchEvent(new MouseEvent("click", { bubbles: true }));
      console.log("🟢 Clicked Text Field:", $(el).attr("data-cbuilder-id") || index);

      // Step 2: Poll for sanitize checkbox in the TOP window
      let interval = setInterval(() => {
        let checkbox = window.top.document.querySelector('input[type="checkbox"][id*="Sanitize"]');
        console.log("🔍 Checkbox lookup (top):", checkbox);

        if (checkbox) {
          if (!checkbox.checked) {
            checkbox.dispatchEvent(new MouseEvent("mousedown", { bubbles: true }));
            checkbox.dispatchEvent(new MouseEvent("mouseup", { bubbles: true }));
            checkbox.dispatchEvent(new MouseEvent("click", { bubbles: true }));
            console.log("✔ Sanitize checkbox clicked:", $(el).attr("data-cbuilder-id") || index);
          } else {
            console.log("ℹ️ Already checked:", $(el).attr("data-cbuilder-id") || index);
          }

          clearInterval(interval);

          // Step 3: Poll for Apply button in the TOP window
          let btnInterval = setInterval(() => {
            let applyBtn = window.top.document.querySelector('#apply-btn');
            console.log("🔍 Apply button lookup (top):", applyBtn);

            if (applyBtn) {
              applyBtn.dispatchEvent(new MouseEvent("mousedown", { bubbles: true }));
              applyBtn.dispatchEvent(new MouseEvent("mouseup", { bubbles: true }));
              applyBtn.dispatchEvent(new MouseEvent("click", { bubbles: true }));
              console.log("✅ Apply button clicked:", $(el).attr("data-cbuilder-id") || index);
              clearInterval(btnInterval);
            }
          }, 500);
        }
      }, 500);

    }, index * 5000);
  });  
</script>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)