KeyFilter is a built-in feature of InputText to restrict user input based on a regular expression.
import { KeyFilterModule } from 'primeng/keyfilter';
KeyFilter provides various presets configured with the pKeyFilter property.
<input pInputText pKeyFilter="int" />
<input pInputText pKeyFilter="num" />
<input pInputText pKeyFilter="money" />
<input pInputText pKeyFilter="hex" />
<input pInputText pKeyFilter="alpha" />
<input pInputText pKeyFilter="alphanum" />
In addition to the presets, a regular expression can be configured for customization.
<input pInputText [pKeyFilter]="blockSpace" />
<input pInputText [pKeyFilter]="blockChars" />
KeyFilter can also be used with reactive forms. In this case, the formControlName property is used to bind the component to a form control.
<form [formGroup]="formGroup">
<label for="integer" class="font-bold block mb-2"> Integer </label>
<input pInputText id="integer" pKeyFilter="int" class="w-full" formControlName="value" />
</form>
Refer to InputText for accessibility as KeyFilter is a built-in add-on of the InputText.
API defines helper props, events and others for the PrimeNG KeyFilter module.
KeyFilter Directive is a built-in feature of InputText to restrict user input based on a regular expression.
Defines the input properties of the component.
Defines emit that determine the behavior of the component based on a given condition or report the actions that the component takes.