-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (28 loc) · 892 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
angular.module('gera-cnpj', ['ngclipboard']);
angular.module('gera-cnpj').filter('prettifyCnpj', function () {
return function (input) {
if (!input || input.length < 14) {
return '-';
}
var pretty = '';
pretty += input.slice(0, 2) + '.';
pretty += input.slice(2, 5) + '.';
pretty += input.slice(5, 8) + '/';
pretty += input.slice(8, 12) + '-';
pretty += input.slice(12, 14);
return pretty;
};
});
angular.module('gera-cnpj').filter('prettifyCPF', function () {
return function (input) {
if (!input || input.length < 11) {
return '-';
}
var pretty = '';
pretty += input.slice(0, 3) + '.';
pretty += input.slice(3, 6) + '.';
pretty += input.slice(6, 9) + '-';
pretty += input.slice(9, 11);
return pretty;
};
});