I have a JQuery mask for phone, depending on how much information the user type I understand if it is cell phone or landline.
The fixed mask: (55) 9999-9999
for mobile: (55) 99999-9999
the mask code:
$("#Telefone").keydown(function () {
var tamanho = $("#Telefone").val().length;
if (tamanho <= 13) {
$("#Telefone").mask("(99)9999-9999");
} else if (tamanho > 13) {
$("#Telefone").mask("(99)99999-9999");
}});
The problem is that only the fixed part works, when the variable size exceeds the value 13 it no longer lets you enter values in the input , even by inverting the code by placing the size > 13 before, can you make this comparison? or some other solution. Note: I use the JQuery mask plug-in.