Skip to content

Instantly share code, notes, and snippets.

@Quaggie
Created December 21, 2015 17:19
Show Gist options
  • Save Quaggie/3c204ac1b6a8d0946b3a to your computer and use it in GitHub Desktop.
Save Quaggie/3c204ac1b6a8d0946b3a to your computer and use it in GitHub Desktop.
/*
* Adds zeros to the beginning of the cnpj in case of database deletion
*/
function verifyCnpj (cnpj) {
var strCnpj = cnpj.toString();
if (cnpj.length === 14) return strCnpj;
if (strCnpj.length < 14) {
return verifyCnpj("0" + strCnpj);
}
return strCnpj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment