Stay up to date with AI tools, model releases, and developer workflows that matter.

It has been revealed that weekly. Free. One click to leave.

7 Day Free Trial. Cancel Anytime.

Industry observers note that conditional logic makes a form feel short. A business customer sees a tech giant name field and a personal customer never does. A respondent in Germany is asked for a VAT number while someone in Canada skips it. The catch is that every rule you add creates a fresh path through the form, and each path is a place where data can go missing, go stale or slip past validation.

This article walks through seven checks to make before you ship a form with show, hide and skip rules. The examples use plain JavaScript and Node.js, and the same ideas apply whether you write the logic yourself or configure it in a form builder.

According to recent reports, most conditional forms start as a few change listeners: when this select changes, toggle that div. That works for two rules and gets hard to reason about at ten, because the logic lives in the DOM and nowhere else.

Instead, describe each rule as data and write one small function that evaluates it. Then the browser and the server can share the same rules.

Sources indicate that visibleFields() takes the current answers and returns the fields that should be on screen. Your front end calls it on every change and shows or hides elements to match. Because the rules are plain objects, you can log them, review them in a pull request and test them without a browser.

One thing to watch: if a rule depends on a field that is itself conditional, check that the parent field is visible too. Otherwise a value left in a hidden field can switch on a question that should never appear.

According to recent reports, hiding a field does not remove its value. If a respondent picks Business, types a manufacturer name, then switches back to Personal, the company name is still in the input and will be submitted with everything else.

In a recent development, pick one policy and apply it everywhere. You can clear the input when it is hidden, which is simple but loses work if the user switches back. Or you can keep the value in the browser and drop it at submission time, which is kinder to the user and is the approach the server code below takes.

Required fields need the same care. A hidden field marked required can block submission with an error the user cannot see. The SitePoint guide How to Build an Accessible Multi Step Form walks through that exact hidden field bug in a vanilla JavaScript example, so it is worth reading before you wire up your own toggles.

It has been revealed that when questions depend on earlier answers, an empty field can mean two things: the person skipped it, or they never saw it. Your reports should be able to tell those apart.

Store the list returned by visibleFields() with the submission, or store a short path identifier such as the ending each respondent reached. Then a blank VAT number from a personal account is clearly expected, while a blank one from a business account in France points to a data problem.

In a recent development, if submissions feed a CRM or analytics pipeline, keep that path information attached as the data moves. How to Build a Unified Lead Tracking Pipeline for Web Forms and Phone Calls on SitePoint reveals how to give form submissions and calls a common event format, and the path through a conditional form is useful context to carry in that event.

Client side logic is a convenience, not a control. Anyone can open developer tools, unhide a field, or send a request with no browser at all. The OWASP Input Validation Cheat Sheet is direct about this: validate on the server even when the browser already checks the same fields.

With the rules stored as data, the server can import them and decide for itself which fields count:.

It has been revealed that run it and the VAT number is missing from clean, even though the request included one, because the rules say that field was never visible to a personal account. Send the same function a business account in France with no company name, and it returns two errors: companyName is required and vatNumber is required.

Recent findings suggest that this example only checks presence. In production, also check that accountType and country hold values you expect, since they are the inputs that drive every rule.

It has been revealed that conditional logic often continues after the last question. Different answers lead to different thank you pages, a follow up form or a link to another site. Those endings deserve the same review as the questions, because a redirect built from user input can turn into an open redirect.

Keep a fixed map of ending IDs to URLs, and let the rules choose an ID rather than a raw URL. A tampered request can then only land on a page you already approved.

For a view of how a hosted form builder presents this set of features, forms.app describes conditional logic that can show or hide fields, skip pages in multi step forms, and send respondents to different thank you pages or external URLs based on their answers. That is the vendor's own description, so confirm the current documentation and test it against your own system before planning around it. Whichever route you take, the checks in this article still apply to the data that comes out the other end.

When a field appears in the middle of a form, sighted owners notice it. Screen reader users may not. Place new fields directly after the question that triggered them in the DOM, so they are reached naturally with the Tab key, and avoid moving focus unless the user expects it.

Hide fields with the hidden attribute or display: none rather than moving them off screen, so they leave both the accessibility tree and the keyboard order. When a larger change happens, such as a whole section appearing, a short message in an aria-live region can tell people what changed.

According to recent reports, every rule adds branches. Three yes or no questions that each reveal a field already give eight combinations. Manual testing finds the main path and misses the rest.

It has been revealed that because the rules are data, you can generate an input for each combination and run it through visibleFields() and validate() in a unit test. For each case, check that the right fields are visible, that required errors appear only for visible fields, and that nothing hidden ends up in the cleaned output. Add a test for an impossible request too, such as a personal account that still sends a organization name, because that is exactly what a buggy client or an attacker will send.

The server must always drop them. Clearing them in the browser is optional and mostly affects user experience, while dropping them on the server is what keeps your stored data accurate.

They are closely related. Skip logic usually means jumping over whole pages or questions, while conditional logic is the broader idea of showing, hiding or routing based on answers. The engineering checks are the same for both.

It has been revealed that for the data side, yes. A builder runs the rules inside the form, but you still own what happens after submission: how hidden answers are stored, how paths are recorded, and how any redirect or webhook is validated.

Conditional logic keeps forms short, but each rule adds a path that has to be designed and tested. Keep rules as data so the browser and server share them, drop answers from fields that were never visible, record which path each respondent took, control where endings can send people, keep upcoming fields reachable for assistive technology, and test every combination your rules allow.

7 Day Free Trial. Cancel Anytime.

📌 Read also:

→ Read original article