alterar campo entre pj e pj (cnpj e cpf) usando mask input https://igorescobar.github.io/jQuery-Mask-Plugin/
/* ainda n usado no projeto
* utilidade: remover mascara dos campos
* */
function removeMask() {
$(".tel").val().replace(/[^\d]+/g,'');
$(".cpf").val().replace(/[^\d]+/g,'');
$(".cnpj").val().replace(/[^\d]+/g,'');
$(".ie").val().replace(/[^\d]+/g,'');
$(".ddd").val().replace(/[^\d]+/g,'');
$(".phone").val().replace(/[^\d]+/g,'');
$(".date").val().replace(/[^\d]+/g,'');
$(".datetime").val().replace(/[^\d]+/g,'');
$(".placa").val().replace(/[^\d]+/g,'');
$(".time").val().replace(/[^\d]+/g,'');
$(".money").val().replace(/[^\d]+/g,'');
$(".cep").val().replace(/[^\d]+/g,'');
}
function removeMaskThis(o) {
o.val().replace(/[^\d]+/g,'');
}
/* ======================================================================== */
/* alterar o tipo da pessoa Fisica ou Juridica */
/* ======================================================================== */
$(document).on('change', "#edttipoPessoa", function (event) {
obj = $("#frmCadastro #edtcpfCnpj");
var oldVal = obj.val().replace(/[^\d]+/g,'');
removeMaskThis(obj);
if ($(this).val() === "F") {
obj.val("");
obj.addClass("cpf").removeClass("cnpj");
obj.parent().find('label').text("CPF");
obj.attr("placeholder", "000.000.000-00");
setMask();
obj.val($('.cpf').masked(oldVal));
} else {
obj.val("");
obj.addClass("cnpj").removeClass("cpf");
obj.parent().find('label').text("CNPJ");
obj.attr("placeholder", "00.000.000/0000-00");
setMask();
obj.val($('.cnpj').masked(oldVal));
}
// $(this).toggleClass("cpf cnpj");
});