KeyFilter

KeyFilter is a built-in feature of InputText to restrict user input based on a regular expression.


import { InputText } from 'primereact/inputtext';
         

KeyFilter provides various presets configured with the keyfilter property.


<InputText keyfilter="int" />
<InputText keyfilter="pint" />
<InputText keyfilter="num" />
<InputText keyfilter="pnum" />
<InputText keyfilter="money" />
<InputText keyfilter="hex" />
<InputText keyfilter="alpha" />
<InputText keyfilter="alphanum" />
<InputText keyfilter="email" />
         

In addition to the presets, a regular expression can be configured for customization.


<InputText keyfilter={/[^s]/} />
<InputText keyfilter={/^[^<>*!]+$/}  />
         
Accessibility guide documents the specification of this component based on WCAG guidelines, the implementation is in progress.

Refer to InputText for accessibility as KeyFilter is a built-in add-on of the InputText.