Skip to content

AngularJS directive to validate CPF/CNPJ numbers.

License

Notifications You must be signed in to change notification settings

kevinchevallier/ng-cpf-cnpj

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm-g-cpf-cnpj

AngularJS directive to validate CPF/CNPJ numbers, using cpf_cnpj.js. All credits to André Gil.

How to install

npm install npm-ng-cpf-cnpj --save

And add to your index.html

<script src="cpf_cnpj/build/cpf.js"></script>
<script src="cpf_cnpj/build/cnpj.js"></script>
<script src="ng-cpf-cnpj/lib/ngCpfCnpj.js"></script>

And inject it to your angular.module

angular.module('myApp', ['ngCpfCnpj']);

How to use

Just add ng-cpf or ng-cnpj to any <input/>. You can also use ui-mask, from ui-utils, to restrict the format:

<form name="myForm">

  <input name="cpf" ng-model="cpf" ng-cpf ui-mask="999.999.999-99" />
  myForm.cpf.$valid: {{ myForm.cpf.$valid }}

  <input name="cnpj" ng-model="cnpj" ng-cnpj ui-mask="99.999.999/9999-99" />
  myForm.cnpj.$valid: {{ myForm.cnpj.$valid }}

</form>

About

AngularJS directive to validate CPF/CNPJ numbers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.9%
  • HTML 0.1%