Fórum Mascara Telefone 9 Dígitos. #430795
10/12/2012
0
Estou querendo que a mascara do telefone será manipulada de acordo com o telefone, se for celular de são paulo a mascara fica assim (99) 99999-9999 senão for ficaria assim (99)9999-9999
Tentei fazer assim porém o digito"?" fica aparecendo.
$('#TxtTel2').focus(function () {
$(this).unmask();
$(this).mask("(99) 99999999?9", { placeholder: " " });
if ($(this).mask().length <= 2) {
$(this).val('( )').caretTo(1);
}
}).focusout(function () {
var phone, element, ddd;
element = $(this);
element.unmask();
phone = element.val().replace(/\D/g, '');
ddd = phone.substring(0, 2);
if (phone.length > 10 && ddd == '11') {
element.mask("(99) 99999-999?9", { placeholder: " " });
element.unmask();
} else {
if (ddd != '11' && phone.length > 10) {
element.val(element.val().substring(0, element.val().length - 1));
}
element.mask("(99) 9999-9999?9", { placeholder: " " });
element.unmask();
}
});
Thiago Garcez
Curtir tópico
+ 0Posts
26/12/2012
Thiago Garcez
Gostei + 0
08/01/2013
Marcio Araujo
Gostei + 0
19/01/2013
Leandro Richard
Gostei + 0
21/01/2013
Danilo Gomes
Gostei + 0
22/01/2013
Thiago Garcez
Gostei + 0
23/01/2013
Leandro Richard
[url]http://code.jquery.com/jquery-1.9.0.min.js[/url]
Gostei + 0
23/07/2013
José
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)