Hello,
I want to create a telephone mask for a field, the problem is that the telephone in Brazil can have two different patterns:
'(99) 9999-9999' or '(99) 99999-9999'
I tried to implement the following Jquery:
$('#fone').mask('(00) 0000-00009');
$('#fone').blur(function(event) {
if($(this).val().length == 15){ // Celular com 9 dígitos + 2 dígitos DDD e 4 da máscara
$('#fone').mask('(00) 00000-0009');
} else {
$('#fone').mask('(00) 0000-00009');
}
});
But I always get the error: "cannot read the mask of null". Is there any easy way to solve this?
Thanks
I want to create a telephone mask for a field, the problem is that the telephone in Brazil can have two different patterns:
'(99) 9999-9999' or '(99) 99999-9999'
I tried to implement the following Jquery:
$('#fone').mask('(00) 0000-00009');
$('#fone').blur(function(event) {
if($(this).val().length == 15){ // Celular com 9 dígitos + 2 dígitos DDD e 4 da máscara
$('#fone').mask('(00) 00000-0009');
} else {
$('#fone').mask('(00) 0000-00009');
}
});
But I always get the error: "cannot read the mask of null". Is there any easy way to solve this?
Thanks
This topic is locked and no more replies can be posted.