> 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

Añada campos de entrada de texto a las aplicaciones de PowerShell Universal con tipos de contraseña, número y multilínea, enmascaramiento, iconos y controladores de eventos de validación.

Un cuadro de texto permite a los usuarios introducir y editar texto.

## Textbox

{% code collapsedlinecount="10" %}

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

{% endcode %}

## Tipos de cuadro de texto

Los cuadros de texto pueden cambiarse para aceptar tipos específicos, como contraseñas, números o correos electrónicos.

### Tipo de contraseña

Un cuadro de texto de contraseña enmascarará la entrada.

{% code collapsedlinecount="10" %}

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

{% endcode %}

### Tipo de número

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

{% code collapsedlinecount="10" %}

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

{% endcode %}

## Multilínea

Puede crear un cuadro de texto multilínea utilizando 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 mediante `-Rows` y `-RowsMax`.

{% code collapsedlinecount="10" %}

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

{% endcode %}

## Interacción

### Recuperar el valor de un cuadro de texto

Puede utilizar `Get-UDElement` para obtener el valor de un cuadro de texto

{% code collapsedlinecount="10" %}

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

{% endcode %}

### Establecer el valor del cuadro de texto

{% code collapsedlinecount="10" %}

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

New-UDButton -OnClick {

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

} -Text "Get textbox value"
```

{% endcode %}

## Iconos

Puede establecer el icono de un cuadro de texto mediante el parámetro `-Icon` y el cmdlet `New-UDIcon`.

{% code collapsedlinecount="10" %}

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

{% endcode %}

## Enmascaramiento

Puede utilizar `-MaskPattern` para definir una máscara para el cuadro de texto. El siguiente es un ejemplo de máscara de cuadro de texto.

{% code collapsedlinecount="10" %}

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

{% endcode %}

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*
* `[]` - hacer la entrada opcional
* `{}` - incluir la parte fija en el valor sin máscara
* `` ` `` - impedir que los símbolos se desplacen hacia atrás

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

El enmascaramiento del cuadro de texto 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.

{% code collapsedlinecount="10" %}

```powershell
New-UDTextbox -OnEnter {
    Invoke-UDEvent -Id 'submit' -Event onClick
}

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

{% endcode %}

## OnBlur

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

{% code collapsedlinecount="10" %}

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

{% endcode %}

## OnValidate

Utilice el controlador de eventos `-OnValidate` para validar la entrada escrita en el cuadro de texto.

{% code collapsedlinecount="10" %}

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

{% endcode %}

## 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.
