Features

Age Requirement to Submit Form

2y agoPending

Hi I love Tally! But I need my form to require the minimum age of 21 to submit. It would be impossible to update it everyday inputting the necessary conditions on the birthdate. For context, I need the form to pass something called "age-gating" which is required to submit for texting campaigns. People must submit their birthdates (in the form of mm/dd/yyyy), but the form needs to filter out people who are younger than 21. Thank you!

and 1 other

3 comments

  1. Hi Emma, I had a similar issue and vibe coded this. I was able to go to my form domain and inject JavaScript to handle this.

    This is one example where I check if the DOB is over 25 years of age: I am happy for you and others to reuse mine and adjust as you see fit. -------------------------------------- <script> document.addEventListener('DOMContentLoaded', function () {

    var DOB_ID = 'FIELD_ID';

    // --- Build dynamic eligible date range --- function formatDate(d) { var months = ['January','February','March','April','May','June', 'July','August','September','October','November','December']; return d.getDate() + ' ' + months[d.getMonth()] + ' ' + d.getFullYear(); } var today = new Date(); // Must be 25 or older — so their DOB must be on or before today minus 25 years var maxDOB = new Date(today.getFullYear() - 25, today.getMonth(), today.getDate());

    // --- Create overlay elements --- var overlay = document.createElement('div'); overlay.id = 'dob-overlay'; overlay.style.cssText = [ 'display:none', 'position:fixed', 'inset:0', 'background:rgba(0,0,0,0.45)', 'z-index:99999', 'align-items:center', 'justify-content:center', 'font-family:Outfit,sans-serif' ].join(';');

    overlay.innerHTML = [ '<div style="background:#fff;border-radius:20px;padding:2rem 2rem 1.5rem;max-width:400px;width:90%;margin:1rem;box-shadow:0 12px 40px rgba(0,0,0,0.15);border:1px solid rgba(255,255,255,0.6);">', '<div style="display:flex;align-items:center;gap:12px;margin-bottom:1rem;">', '<div style="width:40px;height:40px;border-radius:50%;background:#f5f0ff;display:flex;align-items:center;justify-content:center;flex-shrink:0;">', '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#6366f1" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">', '<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>', '<line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/>', '</svg>', '</div>', '<div>', '<p style="margin:0;font-size:1rem;font-weight:700;color:#1a1a1a;">Age eligibility check</p>', '<p style="margin:0;font-size:0.8rem;color:#6b7280;">Community Reconnections</p>', '</div>', '</div>', '<p style="font-size:0.92rem;color:#3d3d3d;line-height:1.6;margin:0 0 0.5rem;">The date of birth entered is outside the eligible age range for this service.</p>', '<p style="font-size:0.92rem;color:#3d3d3d;line-height:1.6;margin:0 0 1.25rem;">Participants must be <strong style="color:#1a1a1a;">25 years of age or older</strong>. Date of birth must be on or before <strong style="color:#1a1a1a;">' + formatDate(maxDOB) + '</strong>.</p>', '<div style="background:#f5f0ff;border-radius:8px;height:4px;margin-bottom:1.25rem;overflow:hidden;">', '<div id="dob-progress" style="height:100%;background:#6366f1;width:100%;border-radius:8px;transition:width 1s linear;"></div>', '</div>', '<div style="display:flex;align-items:center;justify-content:space-between;">', '<span style="font-size:0.8rem;color:#6b7280;">Closing in <strong id="dob-countdown" style="color:#6366f1;">5s</strong></span>', '<button id="dob-ok-btn" style="background:#6366f1;color:#fff;border:none;border-radius:50px;padding:9px 24px;font-size:0.9rem;font-weight:600;font-family:Outfit,sans-serif;cursor:pointer;letter-spacing:0.01em;">OK</button>', '</div>', '</div>' ].join('');

    document.body.appendChild(overlay);

    // --- Clear DOB field (React-safe) --- function clearDOB() { var dobInput = document.getElementById(DOB_ID); if (!dobInput) return; var setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set; setter.call(dobInput, ''); dobInput.dispatchEvent(new Event('input', { bubbles: true })); dobInput.focus(); }

    var countdownTimer = null;

    function closeOverlay() { overlay.style.display = 'none'; if (countdownTimer) clearInterval(countdownTimer); clearDOB(); }

    function showOverlay() { overlay.style.display = 'flex'; var seconds = 5; var progress = document.getElementById('dob-progress'); var countdown = document.getElementById('dob-countdown'); progress.style.width = '100%'; countdown.textContent = seconds + 's';

    if (countdownTimer) clearInterval(countdownTimer); countdownTimer = setInterval(function () { seconds--; countdown.textContent = seconds + 's'; progress.style.width = (seconds / 5 * 100) + '%'; if (seconds <= 0) closeOverlay(); }, 1000); }

    document.getElementById('dob-ok-btn').addEventListener('click', closeOverlay);

    // --- Age check (must be 25 or older) --- function checkAge(value) { if (!value) return; var dob = new Date(value); if (isNaN(dob)) return; // Trigger if their DOB is MORE RECENT than 25 years ago (i.e. under 25) if (dob > maxDOB) { showOverlay(); } }

    // --- State Polling (Bypasses React event suppression) --- var lastKnownValue = '';

    setInterval(function() { var dobInput = document.getElementById(DOB_ID); if (dobInput) { var currentValue = dobInput.value; if (currentValue !== lastKnownValue) { lastKnownValue = currentValue; checkAge(currentValue); } } }, 500);

    }); </script> --------------------------------------

    The only thing you need to change is the field ID and you can get it by inspecting the published form and I have attached an image of my form field ID.

    • img/vmfby9ii8wmbwmi37o38qfnp
  2. Any update on this request. I'm needing one also.

  3. Hi Emma Fisher, thanks for this request! I see how you envision this feature and its intended purpose. Even a workaround solution with Tally seems to be complicated today. I see some other feature requests that would make the workaround easier, but will leave your request as a standalone feature for now.

    While I can't make any promises about if or when it might be implemented, rest assured that you'll see updates here if anything changes. Thanks again for your contribution!