Conditional Logic
Conditional logic allows you to show or hide fields, change field values, and customize form behavior based on user responses. This creates dynamic, personalized form experiences.
What is Conditional Logic?โ
Conditional logic lets you:
- Show/Hide Fields: Display fields only when relevant
- Change Field Values: Auto-populate based on other fields
- Skip Pages: Skip irrelevant pages in multi-page forms
- Customize Messages: Change help text based on responses
Basic Conditional Rulesโ
Show/Hide Fieldsโ
The most common use case: show a field only when certain conditions are met.
Example: Show "Company Name" only if "Account Type" is "Business"
Field: Company Name
Show When: Account Type equals "Business"
Configuration:
- Select the field to conditionally show
- Click "Add Condition"
- Choose trigger field
- Set condition (equals, not equals, contains, etc.)
- Set value(s) to match
Condition Operatorsโ
- Equals: Exact match
- Not Equals: Does not match
- Contains: Contains text/value
- Not Contains: Does not contain
- Greater Than: Numeric comparison
- Less Than: Numeric comparison
- Is Empty: Field is empty
- Is Not Empty: Field has value
Advanced Conditionsโ
Multiple Conditionsโ
Combine multiple conditions with AND/OR logic:
AND Logic (all must be true):
Show "Shipping Address" when:
- "Delivery Method" equals "Ship"
AND
- "Country" equals "United States"
OR Logic (any can be true):
Show "Discount Code" when:
- "Customer Type" equals "VIP"
OR
- "Promotion Code" contains "SAVE"
Nested Conditionsโ
Create complex logic with nested conditions:
Show "Business Details" when:
(Account Type equals "Business" AND Country equals "US")
OR
(Account Type equals "Business" AND Has Tax ID equals "Yes")
Conditional Field Valuesโ
Auto-Populate Fieldsโ
Set field values based on other fields:
Example: Auto-fill "Full Name" from "First Name" and "Last Name"
Field: Full Name
Value: CONCAT(FirstName, " ", LastName)
Conditional Defaultsโ
Set default values based on conditions:
Field: Country Code
Default:
If "Country" equals "United States": "+1"
If "Country" equals "United Kingdom": "+44"
Else: ""
Conditional Validationโ
Make validation rules conditional:
Example: Require "Business Phone" only for business accounts
Field: Business Phone
Required: If "Account Type" equals "Business"
Use Casesโ
Progressive Disclosureโ
Show fields progressively as users provide information:
1. Ask "Are you a business or individual?"
2. If "Business": Show business fields
3. If "Individual": Show personal fields
Skip Logicโ
Skip irrelevant sections:
If "Has Previous Experience" equals "No":
Skip "Experience Details" page
Dynamic Pricingโ
Calculate prices based on selections:
Field: Total Price
Computed:
Base Price +
(If "Premium Features" selected: +$50) +
(If "Support Package" selected: +$25)
Conditional Help Textโ
Change guidance based on responses:
Field: Tax ID
Help Text:
If "Country" equals "US": "Enter your EIN"
If "Country" equals "UK": "Enter your VAT number"
Else: "Enter your tax identification number"
Building Conditional Rulesโ
Step-by-Stepโ
-
Select Target Field:
- Choose the field that will be shown/hidden/modified
-
Add Condition:
- Click "Add Condition" or "Show When"
- Select trigger field
- Choose operator
- Set value(s)
-
Add More Conditions (optional):
- Add additional conditions
- Choose AND/OR logic
-
Test Condition:
- Use preview mode
- Test all condition branches
- Verify behavior
Visual Rule Builderโ
NetPad provides a visual interface for building conditions:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Show this field when: โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ [Field] [Operator] [Value] โ
โ โผ โผ โผ โ
โ Account equals Business โ
โ Type โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ [AND] [OR] [Add Condition] โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Examplesโ
Contact Form with Business/Personalโ
Field: Account Type (Radio)
Options: Personal, Business
Field: Company Name (Text)
Show When: Account Type equals "Business"
Required: If Account Type equals "Business"
Field: Personal Interests (Checkboxes)
Show When: Account Type equals "Personal"
Survey with Skip Logicโ
Page 1: Demographics
- Age
- Location
- Experience Level
Page 2: Experience Details
Show When: Experience Level not equals "None"
- Years of Experience
- Previous Projects
- Skills
Page 3: Feedback
- Always shown
Registration Formโ
Field: Registration Type (Dropdown)
Options: Free, Premium, Enterprise
Field: Credit Card (Text)
Show When: Registration Type not equals "Free"
Required: If Registration Type not equals "Free"
Field: Company Size (Dropdown)
Show When: Registration Type equals "Enterprise"
Options: Small, Medium, Large
Best Practicesโ
- Keep It Simple: Don't overcomplicate conditional logic
- Test Thoroughly: Test all condition branches
- Clear Labels: Make it obvious why fields appear
- Progressive Disclosure: Show fields as needed, not all at once
- User Feedback: Provide clear indication when fields appear/disappear
- Fallback Values: Handle cases where conditions aren't met
- Performance: Avoid too many nested conditions
Common Patternsโ
Show/Hide Based on Selectionโ
Most common pattern:
Field A: Selection
Field B: Show when Field A equals "Option X"
Cascade Selectionsโ
Chain multiple conditional fields:
Field 1: Country
Field 2: State (show when Country selected)
Field 3: City (show when State selected)
Conditional Requiredโ
Make fields required conditionally:
Field: Business Phone
Required: If Account Type equals "Business"
Multi-Condition Logicโ
Complex business rules:
Show "Shipping Options" when:
(Product Type equals "Physical" AND Quantity > 0)
AND
(Delivery Method not equals "Pickup")
Testing Conditional Logicโ
- Test Each Branch: Test all possible condition outcomes
- Test Edge Cases: Test empty values, invalid inputs
- Test Transitions: Verify smooth show/hide animations
- Test Validation: Ensure conditional validation works
- User Experience: Verify logic feels natural
Troubleshootingโ
Field Not Showing:
- Check condition values match exactly (case-sensitive)
- Verify AND/OR logic is correct
- Test condition in preview mode
Field Always Showing:
- Check for conflicting conditions
- Verify condition logic
- Review field visibility settings
Performance Issues:
- Reduce number of conditions
- Simplify nested logic
- Use computed fields for calculations
Next Stepsโ
- Validation - Set up validation rules
- Building Forms - Learn form building basics
- Publishing - Make your form live