EARTHLOOMGuides   Apps

How to add input masks in Bubble for phone, date and SSN fields

Bubble inputs accept any text by default, so users enter phone numbers as 5551234567, 555-123-4567, or (555) 123-4567 interchangeably. That breaks databases, APIs, and downstream automations. You can enforce a single format three ways: the built-in input formatter, a community plugin, or a tiny JavaScript snippet in an HTML element. All work without custom code deployments.

Why this is harder than it looks

Bubble's native input element has no mask property. Builders either rely on placeholder text (which users ignore) or write custom regex workflows that fire on every keystroke and degrade performance. Free marketplace plugins exist but some are unmaintained or conflict with reactive forms. The result is dirty data: phone numbers with mixed separators, dates in DD/MM/YYYY when the API expects MM/DD/YYYY, and SSNs missing hyphens that cause validation failures downstream.

Step by step

  1. Decide which fields need masks. List every input that must follow a strict pattern: phone, date of birth, SSN, ZIP, credit card, ISBN, or custom codes. For each, note the exact pattern (e.g., (999) 999-9999 for US phone, 99/99/9999 for date, 999-99-9999 for SSN) and whether the mask should stay visible after blur. Keep the list short; masking every field adds friction.
  2. Try the native Input Formatter first. In the input element's Appearance tab, enable Input Formatter and choose a preset (Phone US, Date MM/DD/YYYY, etc.) or write a custom pattern using 9 for digits, a for letters, * for alphanumeric. This runs client-side with zero latency. Test on mobile: some presets block paste or misbehave on Android keyboards, so verify the user can still paste a valid value and have it reformat automatically.
  3. Install a maintained free plugin if presets fail. Search the Bubble marketplace for "Input Mask" and sort by updated date. Pick one with recent reviews and a demo page. Install, then in the plugin's element settings map each input's ID to a mask string (e.g., "(999) 999-9999"). Most plugins expose an "unmasked value" state - use that in workflows and database writes so you store clean digits only. Avoid plugins that require a paid plan for basic masking.
  4. Add a lightweight JavaScript mask for total control. Place an HTML element on the page, set it to visible on load, and paste a 20-line vanilla JS mask using the Inputmask library from a CDN (e.g., https://cdn.jsdelivr.net/npm/inputmask@5/dist/inputmask.min.js). Target inputs by Bubble's unique ID (inspect element to find it). This gives you aliases like "phone", "datetime", "regex", and callbacks for oncomplete/onincomplete. It loads once, works offline, and survives Bubble version updates.
  5. Store the unmasked value, display the masked one. Never save the formatted string with parentheses or hyphens. In your workflow, read the plugin's or JS mask's "raw" or "unmasked" state and write only digits to the database. For display elsewhere, reapply the mask in a text element using formatted as text or a repeating group cell with the same pattern. This keeps searches, APIs, and exports clean.
  6. Validate on blur, not on every keystroke. If you add a custom state or workflow to check validity, trigger it when the input loses focus ("when input is changed" fires too often). Show a subtle red border and a tooltip like "Enter a valid US phone number" only after blur. Clear the error on the next focus. This avoids the flicker and performance hit of per-keystroke regex in Bubble's workflow engine.
  7. Test paste, autofill, and keyboard edge cases. Paste a valid number from Notes, use 1Password or browser autofill, tap the field on iOS and Android, and try backspacing through separators. The mask must reformat pasted text, allow autofill to populate, and let the user delete a digit without jumping the cursor to the end. Fix any plugin or JS config that breaks these behaviors before shipping.

Common mistakes

Where Input Mask for Bubble fits in

Input Mask for Bubble provides a dedicated plugin element that applies masks like phone, date, SSN, and custom regex directly in the Bubble editor. It exposes the unmasked value as a state for clean database writes and works client-side with no external calls.

Input Mask for Bubble support and FAQ

FAQ

Why does my masked input still save parentheses and hyphens?

You are saving the input's value instead of the plugin's unmasked value state. Use the raw digits state in your workflow's "Data to send" or "Create a new thing" action.

Can I use different masks for different countries on the same page?

Yes. Add a dropdown for country code, then use conditional logic on the plugin element or JS to swap the mask pattern (e.g., +44 9999 999999 for UK, +1 (999) 999-9999 for US) when the dropdown changes.

Does masking work inside a repeating group for editable rows?

It works if each row's input has a unique ID and you initialize the mask per cell. With the JS method, run the initializer inside the repeating group's "cell loaded" event or use a plugin that auto-binds to dynamic elements.