This component provides a complete solution for formatting, input control, and validation of the Brazilian CNPJ (Cadastro Nacional da Pessoa Jurídica), fully compatible with both the traditional numeric CNPJ and the new alphanumeric CNPJ model established by the Brazilian Federal Revenue Service.
The component applies the official CNPJ mask __.___.___/____-__ in real time, ensuring a consistent and user-friendly typing experience. Cursor positioning is intelligently managed, including advanced scenarios such as Backspace and Delete operations, text selection deletion, and cursor navigation through mask separators, preventing unexpected behavior during editing.
__.___.___/____-__
Input is strictly controlled according to official rules:
Only alphanumeric characters are allowed
The last two digits (check digits) are restricted to numeric values
Input length is limited to 14 logical characters, independent of the mask
The component also includes a client-side validation action that verifies the CNPJ using the official modulus 11 algorithm, supporting:
Numeric CNPJ (legacy model)
Alphanumeric CNPJ (base-36 calculation with letters A–Z)
This validation ensures that the entered value is structurally correct and mathematically valid before submission.
During user interaction, the component continuously exposes the following values through a client action:
Formatted CNPJ (with mask applied)
Clean CNPJ (without mask, containing only alphanumeric characters)
These outputs make it easy to integrate the component with business logic, persistence layers, and external services.
Designed specifically for OutSystems applications, the component is fully compatible with client-side JavaScript (ES5) and follows best practices for performance, usability, and maintainability, making it suitable for enterprise-grade applications and reusable UI libraries.