Preview form
Preview inbox
Sample response. Submit the preview form to try your own.
- What would you like to share?
- An idea
- Tell us more
- A larger order photo would help me check the details.
- Add a photo or screenshot (optional)
- order-preview.png
Form code
Live snippet synced with your customized fields and visual style.
<form action="https://forms.wiztrom.com/f/YOUR_FORM_ID" method="post" accept-charset="UTF-8" enctype="multipart/form-data" class="wiztrom-form">
<div data-wf-field="topic" data-wf-step="">
<fieldset>
<legend>What would you like to share?</legend>
<label><input type="radio" name="topic" required value="An idea"> An idea</label>
<label><input type="radio" name="topic" required value="A problem"> A problem</label>
<label><input type="radio" name="topic" required value="A compliment"> A compliment</label>
</fieldset>
</div>
<div data-wf-field="details" data-wf-step="">
<div><label>Tell us more
<textarea name="details" required></textarea></label></div>
</div>
<div data-wf-field="photo" data-wf-step="" data-wf-optional="">
<div><label>Add a photo or screenshot (optional)
<input type="file" name="photo" aria-describedby="wf-rules-photo" class="wf-file"></label>
<small class="wf-file-limit" id="wf-rules-photo">One file, up to 10 MiB</small></div>
</div>
<div hidden><input name="_wiztrom_hp" tabindex="-1" autocomplete="off"></div>
<div class="wf-actions"><button type="submit">Send feedback</button></div>
</form>
<script>
(() => {
const form = document.currentScript.previousElementSibling;
// Used by the preview and copied into self-contained form embeds.
function enableFieldValidation(form) {
const dnsLabel = /^[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?$/i;
function domain(host) {
const labels = host.split('.');
return host.length <= 253 && labels.length >= 2 && labels.every(label => dnsLabel.test(label))
&& /^(?:[a-z]{2,63}|xn--[a-z\d-]+)$/i.test(labels.at(-1));
}
function website(value) {
if (/[\s\\\x00-\x1f\x7f]/u.test(value) || /%(?![a-f\d]{2})/i.test(value)) return false;
const address = value.replace(/^https?:\/\//i, '');
const authority = address.split(/[/?#]/, 1)[0];
if (!authority || /[@%]/.test(authority) || authority.endsWith(':')) return false;
try {
const url = new URL('https://' + address);
if (url.port === '0') return false;
const host = url.hostname;
if (host.startsWith('[')) return true;
if (/^[\d.]+$/.test(host)) return host === authority.split(':')[0];
return domain(host.replace(/\.$/, ''));
} catch {
return false;
}
}
function allowedDomain(host, domains) {
return !domains?.length || domains.some(domain => domain.trim().toLowerCase() === host.toLowerCase());
}
function validate(control) {
if (control.matches('fieldset[data-wf-sequence="ranking"] select')) {
const slots = Array.from(control.closest('fieldset').querySelectorAll('select'));
const answers = slots.map(slot => slot.value);
const partial = answers.some(Boolean);
for (const slot of slots) {
const duplicate = slot.value && answers.indexOf(slot.value) !== answers.lastIndexOf(slot.value);
slot.setCustomValidity(duplicate ? 'Choose each option once.' : partial && !slot.value ? 'Complete all ranks.' : '');
}
return;
}
if (!control.matches('input, textarea')) return;
const group = control.closest('fieldset[data-wf-rules], fieldset[data-wf-required-group]');
const rules = JSON.parse(control.dataset.wfRules || group?.dataset.wfRules || '{}');
const value = control.value;
let message = '';
if (control.matches('input[type=email]')) {
const [local, host] = value.split('@');
if (value && !(host && domain(host) && value.length <= 254 && local.length <= 64 &&
!local.startsWith('.') && !local.endsWith('.') && !local.includes('..'))) {
message = 'Enter an email address such as name@example.com.';
} else if (value && !allowedDomain(host, rules.domains)) {
message = 'Use one of these domains: ' + rules.domains.join(', ') + '.';
}
} else if (control.matches('input[data-wf-website]')) {
if (value && !website(value)) message = 'Enter a website such as example.com or https://example.com.';
else if (value && rules.domains?.length) {
const host = new URL(/^https?:\/\//i.test(value) ? value : 'https://' + value).hostname.replace(/\.$/, '');
if (!allowedDomain(host, rules.domains)) message = 'Use one of these domains: ' + rules.domains.join(', ') + '.';
}
} else if (control.matches('input[type=text], textarea')) {
if (control.required && value && !value.trim()) message = 'Enter an answer containing more than whitespace.';
if (rules.minLength !== undefined || rules.maxLength !== undefined) {
const length = Array.from(value).length;
const counter = control.closest('label')?.parentElement.querySelector('[data-wf-count]');
if (counter) counter.textContent = length + (length === 1 ? ' character entered.' : ' characters entered.');
if (value && length < rules.minLength) message = 'Enter at least ' + rules.minLength + ' characters.';
if (length > rules.maxLength) message = 'Enter at most ' + rules.maxLength + ' characters.';
}
} else if (control.matches('input[type=number]')) {
if (value && rules.wholeNumber && !Number.isInteger(control.valueAsNumber)) message = 'Enter a whole number.';
} else if (control.matches('input[type=date]')) {
const today = new Date().toISOString().slice(0, 10);
control.min = rules.minDate === 'today' ? today : rules.minDate || '0001-01-01';
control.max = rules.maxDate === 'today' ? today : rules.maxDate || '9999-12-31';
} else if (control.matches('input[type=file]')) {
const file = control.files[0];
const limit = rules.maxFileMiB ?? 10;
if (file && file.size > limit * 1048576) message = 'Choose a file of ' + limit + ' MiB or less.';
else if (file && rules.extensions?.length) {
const extension = file.name.match(/\.[^.]+$/)?.[0].toLowerCase();
if (!rules.extensions.some(ext => ext.trim().toLowerCase() === extension)) {
message = 'Choose a file with one of these extensions: ' + rules.extensions.join(', ') + '.';
}
}
} else if (control.matches('input[type=checkbox]') && group) {
const count = group.querySelectorAll('input:checked').length;
if (!count && group.hasAttribute('data-wf-required-group')) message = 'Select at least one option.';
else if (count > 0 && count < rules.minSelections) message = 'Select at least ' + rules.minSelections + ' options.';
else if (count > rules.maxSelections) message = 'Select at most ' + rules.maxSelections + ' options.';
group.querySelector('input').setCustomValidity(message);
return;
}
control.setCustomValidity(message);
}
function refresh() {
form.querySelectorAll('input, textarea, select').forEach(validate);
}
const events = new AbortController();
const listener = { signal: events.signal };
form.addEventListener('wiztrom:restore-question', event => event.target.querySelectorAll('input, textarea, select').forEach(validate), listener);
form.addEventListener('input', event => validate(event.target), listener);
form.addEventListener('change', event => validate(event.target), listener);
form.addEventListener('reset', () => queueMicrotask(refresh), listener);
// Re-evaluate rolling calendar bounds on forms left open overnight.
let midnight;
function refreshDates() {
const dates = Array.from(form.querySelectorAll('input[type=date][data-wf-rules]'))
.filter(input => {
const rules = JSON.parse(input.dataset.wfRules);
return rules.minDate === 'today' || rules.maxDate === 'today';
});
if (!dates.length) return;
dates.forEach(validate);
const tomorrow = new Date();
tomorrow.setUTCHours(24, 0, 0, 0);
midnight = setTimeout(refreshDates, Math.max(1, tomorrow.getTime() - Date.now()));
}
form.addEventListener('focusin', event => validate(event.target), listener);
refresh();
refreshDates();
return () => {
clearTimeout(midnight);
events.abort();
};
}
enableFieldValidation(form);
// Also embedded verbatim in the HTML and React exports.
/**
* @param {HTMLFormElement} form
* @param {{initialStep?: number, onStep?: (index: number, count: number) => void}} [options]
*/
function enableFormSteps(form, { initialStep = 0, onStep } = {}) {
const fields = Array.from(form.querySelectorAll('[data-wf-field], [data-wf-step]'));
const submit = form.querySelector('button[type="submit"]');
if (!fields.length || !submit) return;
const stepped = fields[0].hasAttribute('data-wf-step');
const groups = [];
const controls = field => Array.from(field.querySelectorAll('input, select, textarea'));
for (const field of fields) {
if (!groups.length || !field.hasAttribute('data-wf-grouped')) groups.push([]);
groups.at(-1).push(field);
}
const groupFor = new Map();
const destination = new Map();
const jumps = new Map();
groups.forEach((group, i) => group.forEach(field => {
groupFor.set(field, i);
destination.set(field.dataset.wfField, i);
if (field.dataset.wfJumps) jumps.set(field, new Map(Object.entries(JSON.parse(field.dataset.wfJumps))));
}));
const events = new AbortController();
const listener = { signal: events.signal };
const recallLabels = new Map();
function readRecallLabels() {
recallLabels.clear();
for (const field of fields) {
const label = field.querySelector('legend, label');
if (!label || !label.textContent.includes('{{')) continue;
const walker = document.createTreeWalker(label, NodeFilter.SHOW_TEXT);
const nodes = [];
while (walker.nextNode()) {
const node = walker.currentNode;
if (node.textContent.includes('{{') && !node.parentElement.closest('select, textarea, small')) nodes.push([node, node.textContent]);
}
if (nodes.length) recallLabels.set(field, nodes);
}
}
readRecallLabels();
const disabledByRule = new Set();
const offPath = new Set();
const skipped = new Set();
const rules = new Map(fields.map(field => [field, {
required: JSON.parse(field.dataset.wfRequiredWhen || 'null'),
choices: new Map(Object.entries(JSON.parse(field.dataset.wfOptionWhen || '{}'))),
terms: JSON.parse(field.dataset.wfScore || 'null'),
}]));
function applyRules(field, inputs, answers, values) {
const {required, choices, terms} = rules.get(field);
const matches = rule => answers.get(rule.field) === rule.equals;
const mustAnswer = required && matches(required);
if (required) {
field.toggleAttribute('data-wf-optional', !mustAnswer);
const optional = field.querySelector('.wf-optional-label');
if (optional) optional.hidden = mustAnswer;
const group = field.querySelector('fieldset input[type=checkbox]')?.closest('fieldset');
if (group) group.toggleAttribute('data-wf-required-group', mustAnswer);
else for (const input of inputs) if (input.name && input.type !== 'hidden' && !input.closest('[data-wf-unanswered]')) input.required = mustAnswer;
field.dispatchEvent(new Event('wiztrom:restore-question', {bubbles:true}));
}
if (choices.size || required) {
for (const option of field.querySelectorAll('option,input[type=radio]')) {
const rule = choices.get(option.value);
const unanswered = option.closest('[data-wf-unanswered]');
if (!rule && !unanswered) continue;
const unavailable = rule ? !matches(rule) : !!mustAnswer;
const container = option.tagName === 'OPTION' ? option : option.closest('label');
if (unavailable && option.selected) option.closest('select').value = '';
if (unavailable && option.checked) option.checked = false;
option.disabled = unavailable;
container.hidden = unavailable || (!!unanswered && stepped);
container.style.display = container.hidden ? 'none' : '';
}
}
if (terms) {
let total = 0;
for (const term of terms) {
for (const value of values.get(term.field) || []) {
if (term.factor !== undefined) total += Number(value) * term.factor;
else if (Object.hasOwn(term.points || {}, value)) total += term.points[value];
}
}
const rounded = Math.sign(total) * Math.round(Math.abs(total) * 100) / 100;
const result = Math.abs(total) <= 1e12 ? String(rounded) : '';
field.querySelector('output').value = result || 'Total out of range';
inputs[0].value = result;
}
values.set(field.dataset.wfField, inputs.filter(input =>
!input.disabled && !input.matches('input[type=file],input[type=radio]:not(:checked),input[type=checkbox]:not(:checked)')
).map(input => input.value));
}
let current = initialStep;
const progress = document.createElement('p');
progress.tabIndex = -1;
progress.className = 'wf-progress';
function button(label, cls) {
const control = document.createElement('button');
control.type = 'button';
control.textContent = label;
control.className = cls;
return control;
}
const back = button('Back', 'wf-back');
const next = button('Continue', 'wf-next');
const skip = button('Skip', 'wf-skip');
const nativeValidation = form.noValidate;
if (stepped) {
fields[0].before(progress);
submit.before(back, next);
submit.after(skip);
form.noValidate = true;
}
function clearField(field) {
field.dispatchEvent(new Event('wiztrom:clear-answer', { bubbles: true }));
for (const control of controls(field)) {
if (control.matches('[type=radio], [type=checkbox]')) control.checked = false;
else control.value = '';
control.setCustomValidity('');
}
}
const visibleFields = index => groups[index].filter(field => !offPath.has(field));
const visibleGroups = () => groups.map((_, i) => i).filter(i => visibleFields(i).length);
function render() {
const answers = new Map();
const values = new Map();
const recall = new Map();
let sourceGroup = -1;
let skipUntil = 0;
for (const field of fields) {
const { wfField, wfSource, wfAnswer } = field.dataset;
const group = groupFor.get(field);
const visible = (group === sourceGroup || group >= skipUntil) && (!wfSource || answers.get(wfSource) === wfAnswer);
if (visible) {
const restored = offPath.delete(field);
const inputs = controls(field);
for (const input of inputs) if (disabledByRule.delete(input)) input.disabled = false;
applyRules(field, inputs, answers, values);
if (restored) field.dispatchEvent(new Event('wiztrom:restore-question', { bubbles: true }));
if (recallLabels.size) {
for (const [node, text] of recallLabels.get(field) || []) {
const label = text.replace(/\{\{([a-zA-Z][\w-]{0,63})(?:\|([^{}]{0,60}))?\}\}/g,
(_, key, fallback) => recall.get(key) || fallback || '…');
if (node.textContent !== label) node.textContent = label;
}
recall.set(wfField, inputs.filter(input => !input.disabled && !input.matches('input[type=file], input[type=checkbox]:not(:checked), input[type=radio]:not(:checked)'))
.map(input => {
if (!input.value) return '';
if (input.tagName === 'SELECT') return input.selectedOptions[0]?.textContent || input.value;
const translated = input.closest('label')?.querySelector('[data-wf-option-label]');
return translated?.textContent || input.value;
}).filter(Boolean).join(', ').slice(0, 256));
}
const selected = inputs.find(input => input.matches('select, input[type=radio]:checked'));
if (selected) {
answers.set(wfField, selected.value);
const target = jumps.get(field)?.get(selected.value);
if (target && sourceGroup !== group) {
sourceGroup = group;
skipUntil = target === '$end' ? groups.length : destination.get(target) ?? group;
}
}
} else {
if (!offPath.has(field)) clearField(field);
offPath.add(field);
for (const input of controls(field)) if (!input.disabled) {
input.disabled = true;
disabledByRule.add(input);
}
}
}
const path = visibleGroups();
if (!path.includes(current)) current = path.find(i => i > current) ?? path.at(-1) ?? 0;
groups.forEach((group, index) => group.forEach(field => {
field.hidden = offPath.has(field) || (stepped && index !== current);
}));
if (!stepped) return;
const pos = path.indexOf(current);
const last = pos === path.length - 1;
back.textContent = form.dataset.wfUiBack || 'Back';
next.textContent = form.dataset.wfUiNext || 'Continue';
progress.textContent = (form.dataset.wfUiProgress || 'Step {step} of {total}').replaceAll('{step}',String(pos+1)).replaceAll('{total}',String(path.length));
back.hidden = pos === 0;
next.hidden = last;
submit.hidden = !last;
skip.hidden = !visibleFields(current).every(field => field.hasAttribute('data-wf-optional'));
skip.textContent = last ? form.dataset.wfUiSkipSubmit || 'Skip and submit' : form.dataset.wfUiSkip || 'Skip';
fields.forEach(field => field.querySelectorAll('[data-wf-unanswered]').forEach(label => { label.hidden = true; }));
}
function announce(completedStep) {
if (onStep) {
const path = visibleGroups();
onStep(path.indexOf(current), path.length);
}
form.dispatchEvent(new CustomEvent('wiztrom:step', { bubbles: true, detail: { step: current + 1, completedStep } }));
}
function focusStep() {
const target = visibleFields(current)
.map(field => field.querySelector('[data-wf-step-focus]')).find(Boolean) || progress;
target.focus({ preventScroll: true });
target.scrollIntoView({ block: 'nearest', inline: 'nearest' });
}
function navigate(index) {
if (index === undefined) return;
const previous = current;
current = index;
render();
announce(index > previous ? previous + 1 : undefined);
focusStep();
}
function invalidField(fieldsToCheck) {
return fieldsToCheck.flatMap(controls).find(input => input.matches(':invalid') && !input.disabled);
}
function advance() {
const invalid = invalidField(visibleFields(current));
if (invalid) invalid.reportValidity();
else navigate(visibleGroups().find(i => i > current));
}
function changed(event) {
skipped.delete(event.target.name);
render();
}
form.addEventListener('wiztrom:language', () => {readRecallLabels(); render();}, listener);
form.addEventListener('input', changed, listener);
form.addEventListener('change', changed, listener);
form.addEventListener('formdata', event => {
for (const name of skipped) event.formData.delete(name);
}, listener);
skip.addEventListener('click', () => {
if (submit.disabled || skip.hidden) return;
for (const field of visibleFields(current)) {
clearField(field);
for (const input of controls(field)) skipped.add(input.name);
}
render();
const following = visibleGroups().find(i => i > current);
if (following === undefined) form.requestSubmit(submit);
else navigate(following);
}, listener);
next.addEventListener('click', advance, listener);
back.addEventListener('click', () => {
if (!submit.disabled) navigate(visibleGroups().filter(i => i < current).at(-1));
}, listener);
if (stepped) {
form.addEventListener('click', event => {
if (event.detail > 0 && event.target.matches('input[type=radio]') && visibleFields(current).length === 1 &&
visibleFields(current)[0].contains(event.target)) {
render();
// A selected answer can reveal a grouped question on this same screen.
if (visibleFields(current).length === 1) advance();
}
}, listener);
form.addEventListener('submit', event => {
if (visibleGroups().some(index => index > current)) {
event.preventDefault();
event.stopImmediatePropagation();
advance();
return;
}
const invalid = invalidField(fields.filter(field => !offPath.has(field)));
if (invalid) {
event.preventDefault();
event.stopImmediatePropagation();
navigate(groups.findIndex(group => group.some(field => field.contains(invalid))));
invalid.reportValidity();
}
}, { ...listener, capture: true });
}
const observer = new MutationObserver(render);
observer.observe(form, { attributes: true, attributeFilter: ['data-wf-optional'], subtree: true });
form.addEventListener('reset', () => queueMicrotask(() => {
if (events.signal.aborted) return;
skipped.clear();
current = 0;
render();
if (stepped) announce();
}), listener);
render();
if (stepped) {
announce();
if (initialStep !== 0) focusStep();
}
return () => {
observer.disconnect();
events.abort();
for (const nodes of recallLabels.values()) for (const [node, text] of nodes) node.textContent = text;
for (const input of disabledByRule) input.disabled = false;
fields.forEach(field => {
field.hidden = false;
field.querySelectorAll('[data-wf-unanswered]').forEach(label => { label.hidden = false; });
});
if (stepped) {
form.noValidate = nativeValidation;
submit.hidden = false;
progress.remove();
back.remove();
next.remove();
skip.remove();
}
};
}
enableFormSteps(form);
})();
</script>How to use this form
Deploy this template on your site in four steps.
Create the form in Wiztrom
Select Continue to workspace to save "Guided feedback" (3 fields) and generate your live endpoint. When connecting manually, copy the form ID from Forms → Setup.
Add the HTML, CSS, or React code to your site
Paste the markup into your page, pair it with the CSS rules for .wiztrom-form, and replace YOUR_FORM_ID in https://forms.wiztrom.com/f/YOUR_FORM_ID. Keep your required field names (topic, details) matching your Wiztrom form schema. Keep enctype="multipart/form-data" on HTML forms so file uploads transmit cleanly.
Enable destinations and spam protection
In Forms, configure email notifications, Slack, Notion, Airtable, Google Sheets, Discord, or signed webhooks. Leave _wiztrom_hp hidden for honeypot filtering, and optionally add allowed origins or Cloudflare Turnstile in Spam protection.
Send one live test and confirm receipt
Submit a test entry from your published page and verify it appears in Inbox (uploaded files are scanned for malware before download). Open Deliveries to confirm alerts and webhook attempts succeeded.
Relevant guides
Curated documentation for this form’s code format, field types, and delivery checks.
Create a contact form in HTML
Walks through placing semantic <form> markup on a page, setting method="post", and handling redirects. Relevant as the baseline embed steps for deploying Guided feedback HTML and CSS.
Add file uploads to an HTML form
Covers multipart/form-data requests, 10 MiB per-file / 25 MiB request limits, and inbox file retrieval. Relevant because your Guided feedback template includes file upload fields.
Check whether a form attachment is safe to download
Explains Wiztrom's automatic malware scan states and why encrypted archives are withheld. Relevant whenever external visitors attach files to Guided feedback.
Protect a website form from spam
Explains how Wiztrom holds _wiztrom_hp honeypot hits in Spam, locks intake to trusted browser origins, and adds Cloudflare Turnstile. Relevant because the generated Guided feedback code includes _wiztrom_hp.
Similar forms
More starters in Customer service and closely related workflows.
Contact form
Give visitors a direct way to ask a question or start a conversation.
View templateFeedback survey
Ask how an experience went and what you could improve.
View templateReturn request
Collect the order, item, and reason before arranging the next step.
View templateSupport request
Get the account details and context you need to help a customer.
View template