@@ -907,12 +907,14 @@ function plPlCheck(tin) {
907907}
908908
909909/*
910- * pt-BR validation function
911- * (Cadastro de Pessoas Físicas (CPF, persons)
912- * Cadastro Nacional de Pessoas Jurídicas (CNPJ, entities)
913- * Both inputs will be validated.
914- * CNPJ supports both numeric (legacy) and alphanumeric format (starting July 2026).
915- */
910+ * pt-BR validation function
911+ * (Cadastro de Pessoas Físicas (CPF, persons)
912+ * Cadastro Nacional de Pessoas Jurídicas (CNPJ, entities)
913+ * Both inputs will be validated.
914+ * CPF accepts formatted (XXX.XXX.XXX-XX) and unformatted input;
915+ * formatting is stripped before validation.
916+ * CNPJ supports both numeric (legacy) and alphanumeric format (starting July 2026).
917+ */
916918
917919/**
918920 * Convert a CNPJ character to its numeric value for check digit calculation.
@@ -966,6 +968,9 @@ function validateCnpj(cnpj) {
966968}
967969
968970function ptBrCheck ( tin ) {
971+ // Strip CPF formatting (XXX.XXX.XXX-XX)
972+ tin = tin . replace ( / [ . \- / ] / g, '' ) ;
973+
969974 if ( tin . length === 11 ) {
970975 let sum ;
971976 let remainder ;
@@ -1205,7 +1210,7 @@ const taxIdFormat = {
12051210 'mt-MT' : / ^ \d { 3 , 7 } [ A P M G L H B Z ] $ | ^ ( [ 1 - 8 ] ) \1\d { 7 } $ / i,
12061211 'nl-NL' : / ^ \d { 9 } $ / ,
12071212 'pl-PL' : / ^ \d { 10 , 11 } $ / ,
1208- 'pt-BR' : / (?: ^ \d { 11 } $ ) | (?: ^ [ A - Z 0 - 9 ] { 12 } \d { 2 } $ ) / i,
1213+ 'pt-BR' : / (?: ^ \d { 3 } \. \d { 3 } \. \d { 3 } - \d { 2 } $ ) | (?: ^ \d { 11 } $ ) | (?: ^ [ A - Z 0 - 9 ] { 12 } \d { 2 } $ ) / i,
12091214 'pt-PT' : / ^ \d { 9 } $ / ,
12101215 'ro-RO' : / ^ \d { 13 } $ / ,
12111216 'sk-SK' : / ^ \d { 6 } \/ { 0 , 1 } \d { 3 , 4 } $ / ,
0 commit comments