Raw New Markdown
Generating updated version of doc...
Rendered New Markdown
Generating updated version of doc...
---
title: UserNameTextBox UI element
description: Describes the Microsoft.Compute.UserNameTextBox UI element for Azure portal. Enables users to provide Windows or Linux user names.
ms.topic: reference
ms.custom: linux-related-content
ms.date: 06/21/2024
---
# Microsoft.Compute.UserNameTextBox UI element
A text box control with built-in validation for Windows and Linux user names.
## UI sample

## Schema
```json
{
"name": "element1",
"type": "Microsoft.Compute.UserNameTextBox",
"label": "User name",
"defaultValue": "",
"toolTip": "",
"constraints": {
"required": true,
"regex": "^[a-z0-9A-Z]{1,30}$",
"validationMessage": "Only alphanumeric characters are allowed, and the value must be 1-30 characters long."
},
"osPlatform": "Windows",
"visible": true
}
```
## Sample output
```json
"Example name"
```
## Remarks
- If `constraints.required` is set to `true`, then the text box must have a value to validate successfully. The default value is `true`.
- `osPlatform` must be specified and can be either **Windows** or **Linux**.
- `constraints.regex` is a JavaScript regular expression pattern. If specified, then the text box's value must match the pattern to validate successfully. The default value is `null`.
- `constraints.validationMessage` is a string to display when the text box's value fails the validation specified by `constraints.regex`. If not specified, then the text box's built-in validation messages are used. The default value is `null`.
- This element has built-in validation that is based on the value specified for `osPlatform`. The built-in validation can be used with a custom regular expression. If a value for `constraints.regex` is specified, then both the built-in and custom validations are triggered.
## Next steps
- For an introduction to creating UI definitions, see [Getting started with CreateUiDefinition](create-uidefinition-overview.md).
- For a description of common properties in UI elements, see [CreateUiDefinition elements](create-uidefinition-elements.md).