Forms 2.0 - Reactive Forms
This page is preliminary and subject to change as Forms 2.0 continues to be developed.
A reactive form responds to the user as they fill it in: a field appears when the user picks an answer, a total updates when a quantity changes, a button is enabled once the required details are there. In Forms 2.0, you get this with short JavaScript expressions on the fields. They run in the browser, straight away, without a request to the server.
What you can make reactive
| To | Use | On the field's settings |
|---|---|---|
| Show or hide a field | Reactive Visibility Rule | Visibility settings > React to Field Changes |
| Enable or disable a field | Dynamically Enabled JS Conditional Expression | Enabled settings > Enable Dynamically |
| Calculate a field's value | Value | Field Automations |
| Run your own code when a value changes | On Change | Field Automations |
| Run your own code when a field is clicked | On Click | Field Automations |
| Reload a dropdown's items when other fields change | Refresh Data and When Fields Change | The Dropdown's data source settings |
Visibility and enabled rules are set on any field that supports them, including containers. A rule on a Section or Layout Container shows, hides, enables, or disables everything inside it at once. See Common Field Settings.
Writing expressions
An expression is a piece of JavaScript. The form's fields are in the form object, by name:
form.Country.value === "United States"
A field inside a Section or Repeater uses its full name, in brackets: form['Billing:Country'].value. In a field inside a Repeater entry, form['Phones:Type'] reads the field in the same entry, so each entry reacts to its own values.
What .value holds depends on the field type:
| Field | .value | Example |
|---|---|---|
| Text Box, Textarea, Password | Text | form.Name.value.trim().length > 0 |
| Number | A number, or empty | form.Quantity.value > 10 |
| Dropdown | The selected item's value | form.Country.value === "RO" |
| Date | An ISO date, yyyy-mm-dd | form.Start.value >= "2027-01-01" |
| Money | An object with amount and currencyCode | form.Price.value.amount > 1000 |
| Phone | An object with countryCode and number | form.Phone.value.countryCode === "US" |
The Reactive Visibility Rule and Dynamically Enabled expressions must give true or false. The Value expression gives the field's new value. On Change and On Click are full snippets of code, written in a code editor, that can do more than one thing.
When expressions run
- When the form opens, every expression runs once, so the form starts in the right state.
- When a field it reads changes, the expression runs again. Forms 2.0 tracks which fields each expression reads, so you don't list them anywhere.
form.Quantity.value * form.Price.value.amountreruns when either field changes. - Self-references are ignored. A Value expression that reads its own field would loop forever, so the form ignores that dependency and shows a message.
- Errors are logged. If an expression fails, the error is written to the browser console with the field's name, and the rest of the form keeps working.
Examples
Show a field based on an answer
The form has an IsBusiness Dropdown with the items Yes and No. On a CompanyName field, check React to Field Changes and set the Reactive Visibility Rule to:
form.IsBusiness.value === "Yes"
Turn on Remove From Layout When Not Visible to close the gap when it's hidden.
Calculate a total
On a Total field, set Value to:
form.Quantity.value * form.UnitPrice.value
Make Total disabled, with Submit Value When Disabled on, so the user can't edit it but it's still submitted.
Enable a button once the form is filled in
On a Submit button, check Enable Dynamically and set the expression to the following, where AcceptTerms is a Yes/No dropdown:
form.Email.value.trim() !== "" && form.AcceptTerms.value === "Yes"
A dropdown that depends on another
For a City dropdown whose items depend on the selected Country, use the Country's value in the City's data source, turn on Refresh Data, and add Country under When Fields Change. The city list reloads each time the country changes. See Dropdown.
Things to keep in mind
- The browser isn't a security boundary. A hidden or disabled field can still be changed by a user who knows their way around the browser's developer tools. The server checks the submitted values with the fields' validators, so put rules that must hold in Field Validators or in the button's actions, not only in a visibility or enabled rule.
- Hidden and disabled fields aren't submitted unless Submit Value When Not Visible or Submit Value When Disabled is on. Fields that aren't submitted have no token in the button's actions.
- Load-time conditions are different. Visible on Load, Enabled on Load, and Active can use C# conditions with server tokens such as
[HasRole:Admins]. They're evaluated once, on the server, when the form opens. The reactive rules can't use server tokens. - Need data from the server? Expressions only see the values on the form. To react with data from a database or an API, use a button with a refresh action, such as Refresh Field Data, or a dropdown with Refresh Data.
Related
- Common Field Settings - where each setting lives
- Working with Form Data - reading values on the server
- Lifecycle - when the browser starts the expressions
Last updated: November 18, 2026