แก้ไข

แชร์ผ่าน


Microsoft.Compute.UserNameTextBox UI element

A text box control with built-in validation for Windows and Linux user names.

UI sample

Microsoft.Compute.UserNameTextBox

Schema

{
  "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

"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