# Data Validation

> Constrain cell input with SheetValidation rules or the Data Validation dialog, and configure combo boxes, masks and other interactive cell types.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Sheet Control > Spreadsheet Documents > Data Validation
- **1246 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/spreadsheets/validation/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/spreadsheets/validation/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/spreadsheets/validation/llms-full.txt

---

Data validation constrains the input a user can enter in a cell. Through supported rule definitions, it can provide list and dropdown choices, numeric and date bounds and custom conditions. Apply rules to intentional worksheet ranges, and test both valid and invalid entries.

You inspect, add, update and remove validation rules with the validation command of the ribbon and its dialog, or in code with `sheet.validation`. The TypeScript reference entry [ValidationRule](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/validationrule/llms-full.txt) lists the supported rule types, operators, messages and options.

### Configure a Rule in the Dialog

Select the intended input cells and choose **Data → Data Validation**. This example allows a whole number of Units between 1 and 500:

![Data Validation with the Error Alert section open, the validation-error switch, Stop style, title and message fields](https://docs.textcontrol.com/assets/img/tx-sheet-control/data-validation-dialog.28b34c6d.webp)

1. Open **Settings** and choose the allowed type and the operator.
2. Fill in the bounds or the list source that the rule requires. A list rule shows choice and source settings instead of the numeric-bound fields.
3. Open **Input Message** to configure the prompt shown on selection, or **Error Alert** to configure the error style, title and message.
4. Select **Apply** to commit the rule, or **Cancel** to discard the draft.

Only one section opens at a time. The frame and bottom actions stay fixed while the settings scroll. Turning an input or error message off disables its fields in place, so their rows stay aligned and their draft text remains available when the message is enabled again.

### Manage Rules in Code

`sheet.validation` is the [Worksheet.validation](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/worksheet/validation-property/llms-full.txt) property. It returns the [SheetValidation](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/sheetvalidation/llms-full.txt) of the worksheet, with these methods:

| Method | Purpose |
|---|---|
| [list](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/sheetvalidation/list-method/llms-full.txt) | Returns detached rule definitions in their enforcement order. |
| [set](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/sheetvalidation/set-method/llms-full.txt) | Replaces the rules on an exact target range. |
| [remove](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/sheetvalidation/remove-method/llms-full.txt) | Removes rules by identity, or all rules when no identity is supplied. |
| [check](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/sheetvalidation/check-method/llms-full.txt) | Checks the current value without modifying the cell or showing a dialog. |

### Design a Validation Workflow

1. Store typed values and define the intended data type.
2. Choose a rule and a target range.
3. Supply a useful prompt and error message.
4. Test typing, paste, fill and programmatic updates.
5. Verify imported and exported validation in representative XLSX files.

Dropdown lists are useful for small, stable categories. [Named ranges](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/named-ranges/llms-full.txt) can make list sources more maintainable. Keep formula-based conditions within the supported calculation scope, and account for empty values deliberately.

### Add Entry Controls With Cell Types

Supported cell-type configurations, described by [CellTypeDefinition](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/celltypedefinition/llms-full.txt), provide additional entry controls such as button-style and choice-style cells. Custom cell renderers and editors belong to the application and must be registered with the control's cell-type registry, the [CellTypeRegistry](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/celltyperegistry/llms-full.txt). Executable registration code is not serialized as workbook content.

### Configure a Cell Type in the Editor

Select the cell and choose **Insert → Cell Type**. Choose **Combo Box**, **Button**, **Radio List**, **Input Mask** or **Custom Renderer**, then configure its **Options** section. Choice controls accept one item per line; a button accepts display text, an input mask accepts its pattern and a custom renderer refers to a renderer registered by the application.

![Cell Type with the Combo Box type, choice text and an Allow Custom Combo Values switch](https://docs.textcontrol.com/assets/img/tx-sheet-control/cell-type-dialog.710b97a8.webp)

With **Allow Custom Combo Values** enabled, the cell combines a text field with a dropdown arrow. The arrow opens every configured choice, including when the current value already matches an item. Select an item to store its configured value, or type a custom value and press Enter. Arrow keys navigate the open list, Escape closes it and Tab commits typed text. A locked cell on a protected sheet disables both entry and expansion.

The dialog keeps the same outer size when the selected type changes. Only applicable options can receive input or block validation. Choose **Apply** to save the draft, **Cancel** to discard it or **Ordinary Cell** to remove the cell type. Cell types are entry controls; configure validation separately when input also needs a rule.

Button cells show a hand pointer and pressed feedback. Clicking a button keeps the worksheet selection frame visible around the cell. A focused button also accepts Enter or Space; press F2 to edit its underlying cell value, or use the formula bar. Button activation raises the `cellButtonClick` event through `editor.workbook.events`, supplying the sheet ID, cell address and value. Changing a button's configured display text is done through Cell Type options.

### What Validation Does Not Replace

> Important
>
> **Not Authorization.** Validation helps users enter data. It is not server authorization, and it is not a substitute for validating uploaded files and business rules in the host.

Protection and validation have separate purposes. A protected target may reject an otherwise valid change, while a validly entered value can still violate a higher-level business policy.

### Next Steps

- [Worksheet Protection](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/protection/llms-full.txt): lock cells and restrict editing commands beside validation.
- [Events and Cancellation](https://docs.textcontrol.com/tx-sheet-control/spreadsheet-editor/events/llms-full.txt): react to edits in your application.

---

## Nearby

- **Previous:** [Sorting and Filtering](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/sorting-filtering/llms-full.txt)
- **Next:** [Charts and Sparklines](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/charts/llms-full.txt)
