> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/es/aplicaciones/components/inputs/textbox.md).

# Cuadro de texto

Un textbox permite a los usuarios introducir y editar texto.

## Textbox

![](/files/k4aa5SgAnSzlOYnKK4kR)

```powershell
New-UDTextbox -Label 'Standard' -Placeholder 'Textbox'
New-UDTextbox -Label 'Disabled' -Placeholder 'Textbox' -Disabled
New-UDTextbox -Label 'Textbox' -Value 'With value'
```

## Tipos de textbox

Los textbox se pueden cambiar para aceptar tipos específicos, como contraseñas, números o correos electrónicos.

### Tipo contraseña

Un textbox de contraseña enmascarará la entrada.

![](/files/ldMFRUXtwSxwY0YHx7gN)

```powershell
New-UDTextbox -Label 'Password' -Type password
```

### Tipo número

Solo acepta números. Algunos navegadores incluirán flechas arriba y abajo para aumentar y disminuir el valor actual.

![](/files/3xYWNaL3MLyqzdWmrswx)

```powershell
New-UDTextbox -Label 'Number' -Type number -Minimum 10 -Maximum 10000 -Value 1234
```

## Multilínea

Puede crear un textbox multilínea usando el parámetro `-Multiline`. Al pulsar Intro se añadirá una nueva línea. Puede definir el número de filas y el número máximo de filas usando `-Rows` y `-RowsMax`.

```powershell
New-UDTextbox -Multiline -Rows 4 -RowsMax 10
```

## Interacción

### Recuperar el valor de un textbox

Puede usar `Get-UDElement` para obtener el valor de un textbox

```powershell
New-UDTextbox -Id 'txtExample' 
New-UDButton -OnClick {
    $Value = (Get-UDElement -Id 'txtExample').value 
    Show-UDToast -Message $Value
} -Text "Get textbox value"
```

### Establecer el valor del textbox

```powershell
New-UDTextbox -Id 'txtExample' -Label 'Label' -Value 'Value'

New-UDButton -OnClick {

    Set-UDElement -Id 'txtExample' -Properties @{
        Value = "test123"
    }

} -Text "Get textbox value"
```

## Iconos

Puede establecer el icono de un textbox usando el parámetro `-Icon` y el cmdlet `New-UDIcon`.

```powershell
New-UDTextbox -Id "ServerGroups" -Icon (New-UDIcon -Icon 'server') -Value "This is my server"
```

![](/files/HsO6ZXDqpjmXvWZTpWeT)

## Enmascaramiento

Puede usar `-MaskPattern` para definir una máscara para el textbox. A continuación se muestra un ejemplo de máscara de textbox.

```powershell
New-UDTextbox -Id 'textbox16' -MaskPattern '+7 (000) 000-00-00'
```

La definición puede contener

* `0` - cualquier dígito
* `a` - cualquier letra
* `*` - cualquier carácter
* otros caracteres que no estén en definiciones personalizadas se consideran *fijos*
* `[]` - hace que la entrada sea opcional
* `{}` - incluye la parte fija en el valor sin máscara
* `` ` `` - evita el desplazamiento hacia atrás de los símbolos

Si un carácter de definición debe tratarse como fijo, debe escaparse con `\\` (p. ej., `\\0`).

El enmascaramiento del textbox está controlado por [imaskjs](https://imask.js.org/guide.html#masked-pattern).

## OnEnter

El controlador de eventos `-OnEnter` se ejecuta cuando el usuario pulsa Intro en el campo de texto. Resulta útil para realizar otras acciones, como hacer clic en un botón, al pulsar Intro.

```powershell
New-UDTextbox -OnEnter {
    Invoke-UDEndpoint -Id 'submit' -Session
}

New-UDButton -Id 'submit' -OnClick {
    Show-UDToast -Message 'From Textbox'
}
```

## OnBlur

El controlador de eventos `-OnBlur` se ejecuta cuando el textbox pierde el foco.

```powershell
New-UDTextbox -OnBlur {
    Show-UDToast "Blurred"
}
```

## OnValidate

Use el controlador de eventos `-OnValidate` para validar la entrada escrita en el textbox.

```powershell
New-UDTextbox -OnValidate {
    if ($EventData.Length -lt 10)
    {
        New-UDValidationResult -ValidationError 'String needs to be longer than 10'
    }
}
```

## API

[New-UDTextbox](/powershell-universal/es/comandos-de-powershell/new-udtextbox.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.devolutions.net/powershell-universal/es/aplicaciones/components/inputs/textbox.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
