PageSourceSearch

https://editorarealiza.com.br/loja/js/cadastro-clientes.js?v=5

js editorarealiza.com.br collected 2026-10-06 21:57:05 UTC 10,496 bytes, 299 lines download raw bytes

1var selecionado;
2
3function ValidarEmail(mail) {
4    var email = $(mail).val();
5    if (Vazio(email)) {
6        $("input[name='email']").removeClass('erro');
7        $('#wmail3.invalid-feedback, #wmail4da.invalid-feedback').hide();
8        return true;
9    }
10
11    if ((email.length != 0) && ((email.indexOf("@") < 1))) {
12        $("input[name='email']").addClass('erro');
13        $('#wmail3.invalid-feedback, #wmail4da.invalid-feedback').html("Endereço de email é inválido").show();
14        return false;
15    }
16    if (true) {
17        return true;
18    }
19    $("input[name='email']").addClass('erro');
20    $('#wmail3.invalid-feedback, #wmail4da.invalid-feedback').html("Endereço de email é inválido").show();
21    return false;
22}
23
24function handleInput(e) {
25    var ss = e.target.selectionStart;
26    var se = e.target.selectionEnd;
27    e.target.value = e.target.value.toLowerCase();
28    e.target.selectionStart = ss;
29    e.target.selectionEnd = se;
30}
31
32function ValidarPassword(senha, confirmasenha, completo) {
33    var newPassword = $(senha).val();
34    var minNumberofChars = 6;
35    var maxNumberofChars = 16;
36    if (newPassword.length < minNumberofChars) {
37        $(senha).addClass('erro');
38        $("#wsenha0").html("Senha inválida, sua senha deve ter no mínimo 6 e máximo 16 caracteres").show();
39        return false;
40    }
41    if (newPassword.length > maxNumberofChars) {
42        $(senha).addClass('erro');
43        $("#wsenha0").html("Senha inválida, sua senha deve ter no mínimo 6 e máximo 16 caracteres").show();
44        return false;
45    }
46    if (($(confirmasenha).val() != newPassword) && completo) {
47        $(senha).addClass('erro');
48        $(confirmasenha).addClass('erro');
49        $("#wsenha0").html("Suas senhas não são iguais").show();
50        return false;
51    }
52    $(senha).removeClass('erro');
53    $(confirmasenha).removeClass('erro');
54    $("#wsenha0").hide();
55    return true;
56}
57
58function verificarDadosClientes() {
59    $('input[name=tipoPessoa]:checked').val(selecionado);
60    var finish = true;
61    if (selecionado == "cadastrofisica") {
62        $('#formcadastro').find('.pf').each(function () {
63            if ($(this).val() == "") {
64                $(this).css('border-color', 'red');
65                finish = false;
66            }
67            else {
68                $(this).css('border-color', '#ccc');
69            }
70        });
71    }
72    else {
73        $('#formcadastro').find('.pj').each(function () {
74            if ($(this).val() == "") {
75                $(this).css('border-color', 'red');
76                finish = false;
77            }
78            else {
79                $(this).css('border-color', '#ccc');
80            }
81        });
82    }
83    return finish;
84
85}
86
87function selecaoTipoPessoa(select) {
88    selecionado = select;
89    $("input[name='email']").val('');
90    $("input[name='email']").removeClass('erro');
91
92    $("input[name='cpf']").val('');
93    $("input[name='cpf']").removeClass('erro');
94
95    $("input[name='cnpj']").val('');
96    $("input[name='cnpj']").removeClass('erro');
97
98    $('#wmail3.invalid-feedback, #wmail4da.invalid-feedback, #icpf, #icnpj').hide();
99    $('#formcadastro').show();
100    if (select == "cadastrofisica") {
101        $('.cadastrofisica').show("slow", function () {
102            $(this).find("input").removeAttr("disabled");
103        });
104        $('.cadastrojuridica').hide("slow", function () {
105            $(this).find("input").attr("disabled", "disabled");
106        });
107    }
108    else {
109        $('.cadastrofisica').hide("slow", function () {
110            $(this).find("input").attr("disabled", "disabled");
111        });
112        $('.cadastrojuridica').show("slow", function () {
113            $(this).find("input").removeAttr("disabled");
114        });
115    }
116}
117
118$(document).ready(function () {
119    $(".select2").select2({
120        width: '100%'
121    });
122
123    $('#cadastrarRepresentante').click(function () {
124        $('#representanteIntro').hide();
125        $('#cadastroRepresentante').show();
126    });
127
128    $("#finalizacadastro").click(function (e) {
129
130        e.preventDefault();
131        if (!verificarDadosClientes()) {
132            return false;
133        }
134        if (!ValidarPassword('#senha', '#confirmasenha', true)) {
135            return false;
136        }
137
138        var termos = $("#termosecondicoes").is(":checked");
139        if ($("#termosecondicoes").is(":checked") == false) {
140            $('#w.invalid-feedback').html("Você precisa aceitar os termos e condições para efetuar o cadastro").show();
141            return false;
142        } else {
143            $('#w.invalid-feedback').hide();
144        }
145
146        // const emailPJ = $(".cadastrojuridica input[name='email']");
147        // const emailPF = $(".cadastrofisica input[name='email']");
148        // if (!(emailPJ.val().length > 0) && (emailPF.val().length > 0)) {
149        //     if (!ValidarEmail(emailPF)) {
150        //         return false;
151        //     }
152        // } else if ((emailPJ.val().length > 0) && !(emailPF.val().length > 0)) {
153        //     if (!ValidarEmail(emailPJ)) {
154        //         return false;
155        //     }
156        // } else {
157        //     $(".cadastrojuridica input[name='email'], .cadastrofisica input[name='email']").addClass('erro');
158        //     $('#wmail3.invalid-feedback, #wmail4da.invalid-feedback').html("Endereço de email é inválido").show();
159        //     return false;
160        // }
161
162        const cep = $("#cep").val();
163        $.getJSON("//viacep.com.br/ws/" + cep + "/json/?callback=?", function (dados) {
164
165            if (("erro" in dados)) {
166                bsal("Atenção", "Cep não encontrado!", "warning", null);
167                return;
168            }
169        });
170
171        if ($("#radioPF").is(":checked")) {
172            const cpf = $("#inputCPF").val();
173            if (!cpfValido(cpf)) {
174                $("input[name=cpf]").addClass('erro');
175                $("#icpf").html("CPF inválido.").show();
176                bsal("Atenção!", "CPF inválido.", "warning");
177                return;
178            }
179        } else if ($("#radioPJ").is(":checked")) {
180            const cnpj = $("#inputCNPJ").val();
181            if (!cnpjValido(cnpj)) {
182                $("input[name=cnpj]").addClass('erro');
183                $("#icnpj").html("CNPJ inválido.").show();
184                bsal("Atenção!", "CNPJ inválido.", "warning");
185                return;
186            }
187        }
188
189        $("#cidade").attr('disabled', false);
190        $("#uf").attr('disabled', false);
191        $("#bairro").attr('disabled', false);
192
193        const recaptchaKey = $("#recaptcha-key").val();
194
195        grecaptcha.ready(function() {
196            grecaptcha.execute(recaptchaKey, { action: 'register' })
197                .then(function(token) {
198                    var dados = $("#formcadastro").serialize();
199                    dados += "&g-recaptcha-response="+token;
200                    loadingFront(true);
201                    axios.post('/cliente/cadastrar', dados).then(function (response) {
202                        if (pixelfacebookativo()) {
203                            fbq('track', 'CompleteRegistration');
204                        }
205                        $("#cidade").attr('disabled', true);
206                        $("#uf").attr('disabled', true);
207                        $("#bairro").attr('disabled', true);
208                        loadingFront(false);
209                        if (response.data == true) {
210                            bsal("Erro", "Cadastrado já existe!", "danger");
211                        } else if (!response.data.aprovar_cadastro) {
212                            bsal("Sucesso", "Parabéns. Agora falta seu cadastro ser aprovado!", "success").then(function () {
213                                window.location.href = "/";
214                            });
215                        } else if (response.data.aprovar_cadastro) {
216                            bsal("Sucesso", "Cadastrado realizado com sucesso!", "success").then(function () {
217                                window.location.href = "/";
218                            });
219                        }
220                    }).catch(function (error) {
221                        sendAlert(error.response);
222                    });
223                });
224        });
225    });
226    $("input[name='senha']").blur(function () {
227        ValidarPassword('#senha', '#confirmasenha', false);
228    });
229    $(".cadastrojuridica input[name='email'],.cadastrofisica input[name='email']").blur(function () {
230        // if (!ValidarEmail(this))
231        //     return;
232        // var email = $(this).val();
233        // if (Vazio(email)) {
234        //     $('#wmail3, #wmail4da').hide();
235        //     return;
236        // }
237        var email = $(this).val();
238        var self = this;
239        axios.get('/cliente/verificaremail/' + email).then(function (response) {
240            if (response.status == 202) {
241                $(self).removeClass('erro');
242                $('#wmail3, #wmail4da').hide();
243            }
244            else {
245                $(self).addClass('erro');
246                $('#wmail3, #wmail4da').html(response.data.mensagem).show();
247            }
248        }).catch(function (e) {
249            $(self).removeClass('erro');
250            $('#wmail3, #wmail4da').hide();
251        });
252    });
253});
254
255function existenteCPFCNPJ(value, type) {
256    if (type == 'cpf') {
257        if (!cpfValido(value)) {
258            $("input[name=" + type + "]").addClass('erro');
259            $("#icpf").html("CPF inválido.").show();
260            return;
261        }
262    } else if (type == 'cnpj') {
263        if (!cnpjValido(value)) {
264            $("input[name=" + type + "]").addClass('erro');
265            $("#icnpj").html("CNPJ inválido.").show();
266            return;
267        }
268    }
269
270    var data = {
271        value: value,
272        type: type
273    };
274
275    axios.post('/cliente/verificarcpfcnpj', data).then(function (response) {
276        var data = response.data;
277        if (data.error) {
278            $("input[name=" + type + "]").addClass('erro');
279            if (type == 'cpf') {
280                $("#icpf").html(data.msg).show();
281            }
282            else if (type == 'cnpj') {
283                $("#icnpj").html(data.msg).show();
284            }
285        }
286        else {
287            $("input[name=" + type + "]").removeClass('erro');
288            $("#icnpj").html('').hide();
289            $("#icpf").html('').hide();
290        }
291    });
292}
293
294function loadingFront(acao) {
295    if (acao)
296        $("#div-pagamento-cielo").css("display", "block");
297    else
298        $("#div-pagamento-cielo").css("display", "none");
299}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.