|
49 | 49 | classEmpty: 'is-empty' |
50 | 50 | }; |
51 | 51 | plugin.cc = function (v) { |
| 52 | + v = String(v || ''); |
52 | 53 | v = v.replace(/\D/g, ""); |
53 | 54 | v = v.replace(/^(\d{4})(\d)/g, "$1 $2"); |
54 | 55 | v = v.replace(/^(\d{4})\s(\d{4})(\d)/g, "$1 $2 $3"); |
55 | 56 | v = v.replace(/^(\d{4})\s(\d{4})\s(\d{4})(\d)/g, "$1 $2 $3 $4"); |
56 | 57 | return v; |
57 | 58 | }; |
58 | 59 | plugin.cep = function (v) { |
| 60 | + v = String(v || ''); |
59 | 61 | v = v.replace(/\D/g, ""); |
60 | 62 | v = v.replace(/^(\d{5})(\d)/, "$1-$2"); |
61 | 63 | return v; |
62 | 64 | }; |
63 | 65 | plugin.cnpj = function (v) { |
| 66 | + v = String(v || ''); |
64 | 67 | v = v.replace(/\D/g, ""); |
65 | 68 | v = v.replace(/^(\d{2})(\d)/, "$1.$2"); |
66 | 69 | v = v.replace(/^(\d{2})\.(\d{3})(\d)/, "$1.$2.$3"); |
|
69 | 72 | return v; |
70 | 73 | }; |
71 | 74 | plugin.cpf = function (v) { |
| 75 | + v = String(v || ''); |
72 | 76 | v = v.replace(/\D/g, ""); |
73 | 77 | v = v.replace(/(\d{3})(\d)/, "$1.$2"); |
74 | 78 | v = v.replace(/(\d{3})(\d)/, "$1.$2"); |
75 | 79 | v = v.replace(/(\d{3})(\d{1,2})$/, "$1-$2"); |
76 | 80 | return v; |
77 | 81 | }; |
78 | 82 | plugin.dateBR = function (v) { |
| 83 | + v = String(v || ''); |
79 | 84 | v = v.replace(/\D/g, ""); |
80 | 85 | v = v.replace(/(\d{2})(\d)/, "$1/$2"); |
81 | 86 | v = v.replace(/(\d{2})(\d)/, "$1/$2"); |
82 | 87 | v = v.replace(/(\d{2})(\d{2})$/, "$1$2"); |
83 | 88 | return v; |
84 | 89 | }; |
85 | 90 | plugin.hour = function (v) { |
| 91 | + v = String(v || ''); |
86 | 92 | v = v.replace(/\D/g, ""); |
87 | 93 | v = v.replace(/(\d{2})(\d)/, "$1h$2"); |
88 | 94 | return v; |
89 | 95 | }; |
90 | 96 | plugin.money = function (v) { |
| 97 | + v = String(v || ''); |
91 | 98 | v = v.replace(/\D/g, ""); |
92 | 99 | v = v.replace(/(\d)(\d{8})$/, "$1.$2"); |
93 | 100 | v = v.replace(/(\d)(\d{5})$/, "$1.$2"); |
94 | 101 | v = v.replace(/(\d)(\d{2})$/, "$1,$2"); |
95 | 102 | return v; |
96 | 103 | }; |
97 | 104 | plugin.phone = function (v) { |
| 105 | + v = String(v || ''); |
98 | 106 | v = v.replace(/\D/g, ""); |
99 | 107 | v = v.replace(/^(\d{2})(\d)/g, "($1) $2"); |
100 | 108 | v = v.replace(/(\d)(\d{4})$/, "$1-$2"); |
101 | 109 | return v; |
102 | 110 | }; |
103 | 111 | plugin['phone-usa'] = function (v) { |
| 112 | + v = String(v || ''); |
104 | 113 | v = v.replace(/\D/g, ""); |
105 | 114 | v = v.replace(/^(\d{3})(\d)/g, "($1) $2"); |
106 | 115 | v = v.replace(/(\d)(\d{4})$/, "$1-$2"); |
107 | 116 | return v; |
108 | 117 | }; |
109 | 118 | plugin.rg = function (v) { |
| 119 | + v = String(v || ''); |
110 | 120 | v = v.replace(/\D/g, ""); |
111 | 121 | v = v.replace(/(\d)(\d{7})$/, "$1.$2"); |
112 | 122 | v = v.replace(/(\d)(\d{4})$/, "$1.$2"); |
113 | 123 | v = v.replace(/(\d)(\d)$/, "$1-$2"); |
114 | 124 | return v; |
115 | 125 | }; |
116 | 126 | plugin.time = function (v) { |
| 127 | + v = String(v || ''); |
117 | 128 | v = v.replace(/\D/g, ""); |
118 | 129 | v = v.replace(/(\d{1})(\d{2})(\d{2})/, "$1:$2.$3"); |
119 | 130 | return v; |
|
0 commit comments