Commit ba8c0e7a976a2f3d7ba831eee79bb3142f03066c
1 parent
c7027107
Exists in
master
and in
5 other branches
Phone mask #14
Showing
1 changed file
with
7 additions
and
2 deletions
Show diff stats
core/static/js/base/amadeus.js
... | ... | @@ -61,16 +61,21 @@ function formatarTelefone(campo, evento){ |
61 | 61 | } |
62 | 62 | tamanho = campo.value.length; |
63 | 63 | |
64 | - if((codTecla > 47 && codTecla < 58) && tamanho < 14){ | |
64 | + if(((codTecla > 47 && codTecla < 58) || (codTecla == 8)) && tamanho < 15){ | |
65 | 65 | |
66 | 66 | if(tamanho == 0){ |
67 | 67 | campo.value = "(" + campo.value; |
68 | 68 | }else if( tamanho == 3 ){ |
69 | - campo.value = campo.value + ")"; | |
69 | + campo.value = campo.value + ") "; | |
70 | 70 | }else if(tamanho == 9){ |
71 | 71 | campo.value = campo.value + "-"; |
72 | + }else if(tamanho == 14){ | |
73 | + // alert('oi'); | |
74 | + campo.value = campo.value.slice(0, 4) + campo.value.slice(5, 14); | |
75 | + campo.value = campo.value.slice(0, 8) + campo.value.slice(9, 10) + campo.value.slice(8, 9) + campo.value.slice(10, 14) | |
72 | 76 | } |
73 | 77 | return true; |
78 | + | |
74 | 79 | } else if(codTecla == 0 || codTecla == 8){ |
75 | 80 | return true; |
76 | 81 | } else { | ... | ... |