> 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/it/app/components/inputs/textbox.md).

# Casella di testo

Una textbox consente agli utenti di inserire e modificare del testo.

## Textbox

![](/files/tJDjh5EuZFbCHdTLczje)

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

## Tipi di textbox

Le textbox possono essere impostate per accettare tipi specifici, come password, numeri o email.

### Tipo password

Una textbox di tipo password maschera l'input.

![](/files/Uk7XY7h5B5W1WgomLKLP)

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

### Tipo numero

Accetta solo numeri. Alcuni browser includono frecce su e giù per aumentare e diminuire il valore corrente.

![](/files/7QJiq8wMj8IzhBwtzJEx)

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

## Multilinea

È possibile creare una textbox multilinea utilizzando il parametro `-Multiline`. Premendo invio viene aggiunta una nuova riga. È possibile definire il numero di righe e il numero massimo di righe utilizzando `-Rows` e `-RowsMax`.

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

## Interazione

### Recupero del valore di una textbox

È possibile utilizzare `Get-UDElement` per ottenere il valore di una textbox

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

### Impostazione del valore della textbox

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

New-UDButton -OnClick {

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

} -Text "Get textbox value"
```

## Icone

È possibile impostare l'icona di una textbox utilizzando il parametro `-Icon` e il cmdlet `New-UDIcon`.

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

![](/files/QAEiOIqRtU0QkN98pzhJ)

## Mascheramento

È possibile utilizzare `-MaskPattern` per definire una maschera per la textbox. Di seguito è riportato un esempio di maschera per una textbox.

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

La definizione può contenere

* `0` - qualsiasi cifra
* `a` - qualsiasi lettera
* `*` - qualsiasi carattere
* gli altri caratteri che non sono presenti nelle definizioni personalizzate si intendono *fissi*
* `[]` - rende l'input facoltativo
* `{}` - include la parte fissa nel valore non mascherato
* `` ` `` - impedisce lo spostamento indietro dei simboli

Se un carattere della definizione deve essere trattato come fisso, deve essere preceduto dal carattere di escape `\\` (ad esempio `\\0`).

Il mascheramento della textbox è gestito da [imaskjs](https://imask.js.org/guide.html#masked-pattern).

## OnEnter

Il gestore di eventi `-OnEnter` viene eseguito quando l'utente preme invio nel campo di testo. È utile per eseguire altre azioni, come fare clic su un pulsante, alla pressione di invio.

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

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

## OnBlur

Il gestore di eventi `-OnBlur` viene eseguito quando la textbox perde lo stato attivo.

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

## OnValidate

Utilizzi il gestore di eventi `-OnValidate` per convalidare l'input digitato nella 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/it/comandi-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/it/app/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.
