Skip to content

Repository files navigation

Angular CPF/CNPJ directive

AngularJS directive to validate CPF/CNPJ numbers, using cpf_cnpj.js.

How to install

npm install @letsfullstack/angular-cpf-cnpj --save

And add to your index.html

<scriptsrc="bower_components/cpf_cnpj/build/cpf.js"></script><scriptsrc="bower_components/cpf_cnpj/build/cnpj.js"></script><scriptsrc="bower_components/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:

<formname="myForm"><inputname="cpf" ng-model="cpf" ng-cpfui-mask="999.999.999-99" />
myForm.cpf.$valid: {{ myForm.cpf.$valid }}
<inputname="cnpj" ng-model="cnpj" ng-cnpjui-mask="99.999.999/9999-99" />
myForm.cnpj.$valid: {{ myForm.cnpj.$valid }}
</form>

About

AngularJS directive to validate CPF/CNPJ numbers.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages