PageSourceSearch

https://easysweb.com.mx/registro/includes/funciones_registro3.js

js easysweb.com.mx collected 2026-10-04 09:24:01 UTC 17,083 bytes, 604 lines download raw bytes

1var a = 1;
2var b = 1;
3var c = 1;
4var d = 1;
5var rfc_a = 1;
6$("#btn_show").on("click", function (e) {
7  e.preventDefault();
8  var current = $(this).attr("action");
9
10  if (current == "hide") {
11    $("#password").attr("type", "password");
12    $("#confirmpwd").attr("type", "password");
13    $("#show").addClass("fa-eye-slash").removeClass("fa-eye");
14    $(this).attr("action", "show");
15  } else {
16    $("#password").removeAttr("type");
17    $("#confirmpwd").removeAttr("type");
18    $("#show").addClass("fa-eye").removeClass("fa-eye-slash");
19    $(this).attr("action", "hide");
20  }
21});
22
23function verifica_usuario() {
24  $(".loader").show();
25  usuario = $("#username").val().replace(/\s/g, "");
26  $("#username").val(usuario);
27
28  if (usuario.toString().length >= 6 && usuario.toString().length <= 10) {
29    re = /^[a-zA-Z0-9]+([a-zA-Z0-9](_|-| )[a-zA-Z0-9])*[a-zA-Z0-9]+$/;
30    res = usuario.match(re);
31    if (res == null) {
32      $("#username").addClass("is-invalid");
33      $("#username").val("");
34      notifica(
35        "El usuario sólo puede contener dígitos, letras mayúsculas y minúsculas."
36      );
37    } else {
38      $.ajax({
39        url: "registro/includes/verifica_usuario.php",
40        type: "POST",
41        data: { usuario: usuario },
42        dataType: "json",
43        success: function (response) {
44          $(".loader").hide();
45          $("#username").removeClass("is-invalid");
46          a = 0;
47        },
48        error: function (response) {
49          $(".loader").hide();
50          notifica("Este nombre de usuario ya está en uso. Elige otro.");
51          $("#username").addClass("is-invalid");
52          $("#username").val("");
53          a = 1;
54        },
55      });
56    }
57  } else {
58    $(".loader").hide();
59    notifica("Tú usuario debe tener entre 6 y 10 caracteres.");
60    $("#username").addClass("is-invalid");
61    a = 1;
62  }
63}
64
65function verifica_nombre() {
66  $("#nombre").removeClass("is-invalid");
67  nombre = $("#nombre").val();
68  if (nombre.length < 3) {
69    $("#nombre").addClass("is-invalid");
70    notifica("Llenar correctamente el campo nombre");
71  }
72}
73
74function verifica_rfc() {
75  $(".loader").show();
76  if (
77    $("#rfc").val() == null ||
78    $("#rfc").val().length == 0 ||
79    /^\s+$/.test($("#rfc").val())
80  ) {
81    $("#rfc").addClass("is-invalid");
82    notifica("El campo RFC no debe ir en vacio");
83    $("#rfc").val("");
84    rfc_a = 1;
85    $(".loader").hide();
86  } else {
87    re =
88      /^([A-ZÑ&]{3,4}) ?(?:- ?)?(\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])) ?(?:- ?)?([A-Z\d]{2})([A\d])$/;
89    rfc = $("#rfc").val().toUpperCase();
90    $("#rfc").val(rfc);
91    if (rfc.match(re)) {
92      $("#rfc").removeClass("is-invalid");
93      $.ajax({
94        url: "registro/includes/verifica_rfc.php",
95        type: "POST",
96        data: { rfc: rfc },
97        dataType: "json",
98        success: function (response) {
99          $("#rfc").removeClass("is-invalid");
100          rfc_a = 0;
101        },
102        error: function (response) {
103          notifica("Este RFC ya ha sido registrado en la plataforma.");
104          $("#rfc").addClass("is-invalid");
105          $("#rfc").val("");
106          rfc_a = 1;
107        },
108      });
109      $(".loader").hide();
110      rfc_a = 0;
111    } else {
112      $(".loader").hide();
113      notifica("Su RFC es incorrecto.");
114      $("#rfc").addClass("is-invalid");
115      rfc_a = 1;
116    }
117  }
118}
119
120function verifica_email() {
121  $(".loader").hide();
122  var regla = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
123
124  if (regla.test($("#email").val()) == true) {
125    $("#email").removeClass("is-invalid");
126    b = 0;
127  } else {
128    notifica("El correo no es correcto");
129    $("#email").addClass("is-invalid");
130    b = 1;
131  }
132  $(".loader").hide();
133}
134
135function comprueba_contrasena(element) {
136  contrasena_1 = $("#password").val();
137  contrasena_2 = $("#confirmpwd").val();
138  if (element == 0) {
139    $("#password").removeClass("is-invalid");
140  } else {
141    $("#confirmpwd").removeClass("is-invalid");
142  }
143  if (contrasena_1.length < 6) {
144    if (element == 0) {
145      $("#password").addClass("is-invalid");
146      notifica(
147        "Usa 6 o más caracteres con una combinación de letras mayúsculas, minúsculas y números"
148      );
149    }
150  } else {
151    var regla = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,15}/;
152    if (contrasena_1.match(regla) != null) {
153      if (contrasena_1 == contrasena_2) {
154        c = 0;
155      } else {
156        if (contrasena_2.length != 0) {
157          notifica("Las contraseñas no coinciden");
158          $("#confirmpwd").addClass("is-invalid");
159          $("#password").addClass("is-invalid");
160          $("#confirmpwd").val("");
161        }
162      }
163    } else {
164      notifica(
165        "Al menos un dígito, al menos una minúscula y al menos una mayúscula"
166      );
167      $("#password").addClass("is-invalid");
168    }
169  }
170}
171
172function verifica_telefono1() {
173  $("#cellphone").removeClass("is-invalid");
174  numero = $("#cellphone").val().length;
175  if (!isNaN($("#cellphone").val())) {
176    if (numero != 10) {
177      notifica("Número incorrecto, debe contener 10 dígitos");
178      $("#cellphone").addClass("is-invalid");
179    } else {
180      if ($("#cellphone").val() == "") {
181        notifica("Debe ingresar un número telefónico");
182        d = 1;
183      } else {
184        $("#cellphone").removeClass("is-invalid");
185        d = 0;
186      }
187    }
188  } else {
189    d = 1;
190    $("#cellphone").val("");
191    notifica("Debe ingresar solo números ");
192  }
193}
194
195function verifica_telefono2() {
196  numero = $("#numberphone").val().length;
197  if (numero > 13 || numero < 10) {
198    notifica("Número incorrecto");
199    $("#numberphone").val("").addClass("is-invalid");
200  } else {
201    if ($("#numberphone").val() == "") {
202      notifica(
203        "Debe ingresar un número telefonico, debe contener de 10 a 13 digitos"
204      );
205      d = 1;
206    } else {
207      $("#numberphone").removeClass("is-invalid");
208      d = 0;
209    }
210  }
211}
212
213function notifica(msj) {
214  $.toast({
215    heading: "Error",
216    text: msj,
217    position: "top-right",
218    showHideTransition: "fade",
219    icon: "error",
220    loaderBg: "#e62020",
221    stack: 4,
222    bgColor: "#e62020",
223    extendedTimeOut: 2000,
224  });
225}
226
227function saveregistrer() {
228  $(".loader").show();
229  $("#saver").attr("disabled", true);
230  $("#saver").hide();
231  $("#username").removeClass("is-invalid");
232  $("#email").removeClass("is-invalid");
233  $("#cellphone").removeClass("is-invalid");
234  $("#rfc").removeClass("is-invalid");
235  var username = $("#username").val();
236  var email = $("#email").val();
237  var cellphone = $("#cellphone").val();
238  var rfc = $("#rfc").val();
239  if (a + b + d  > 1) {
240    $("#username").addClass("is-invalid");
241    $("#email").addClass("is-invalid");
242    $("#cellphone").addClass("is-invalid");
243    $("#rfc").addClass("is-invalid");
244    notifica("Verifica los dato introducidos");
245    $(".loader").hide();
246  } else if (a != 0) {
247    $("#username").addClass("is-invalid");
248    notifica("Verifica tu nombre de usuario");
249    $(".loader").hide();
250  } else if (b != 0) {
251    $("#email").addClass("is-invalid");
252    notifica("Verifica tu correo");
253    $(".loader").hide();
254  } else if (d != 0) {
255    $("#cellphone").addClass("is-invalid");
256    notifica("Verifica tu teléfono");
257    $(".loader").hide();
258  } else if (rfc_a != 0) {
259    $("#rfc").addClass("is-invalid");
260    notifica("Verifica tu RFC");
261    $(".loader").hide();
262  } else {
263    $.ajax({
264      url: "includes/register.inclite2.php",
265      method: "POST",
266      data: {
267        username: username,
268        email: email,
269        cellphone: cellphone,
270        rfc: rfc,
271        timbres:timbres
272      },
273      success: function (data) {
274        location.href = data;
275        $(".loader").hide();
276      },
277    });
278  }
279}
280let isValid = false;
281function saveregistrer1() {
282  isValid = false;
283  grecaptcha.reset();
284  $(".loader").show();
285  $("#saver").attr("disabled", true);
286  $("#saver").hide();
287  $("#username").removeClass("is-invalid");
288  $("#email").removeClass("is-invalid");
289  $("#cellphone").removeClass("is-invalid");
290  //$("#rfc").removeClass("is-invalid");
291  if (a + b + d  > 1) {
292    $("#username").addClass("is-invalid");
293    $("#email").addClass("is-invalid");
294    $("#cellphone").addClass("is-invalid");
295    //$("#rfc").addClass("is-invalid");
296    notifica("Verifica los dato introducidos");
297    $(".loader").hide();
298  } else if (a != 0) {
299    $("#username").addClass("is-invalid");
300    notifica("Verifica tu nombre de usuario");
301    $(".loader").hide();
302  } else if (b != 0) {
303    $("#email").addClass("is-invalid");
304    notifica("Verifica tu correo");
305    $(".loader").hide();
306  } else if (d != 0) {
307    $("#cellphone").addClass("is-invalid");
308    notifica("Verifica tu teléfono");
309    $(".loader").hide();
310  }/* else if (rfc_a != 0) {
311    $("#rfc").addClass("is-invalid");
312    notifica("Verifica tu RFC");
313    $(".loader").hide();
314  } */else if (!$("#terms").is(":checked")) {
315    validaTerminos1();
316  } else {
317    isValid = true;
318    grecaptcha.execute();
319  }
320}
321
322var reset = () => {
323  $("#username")[0].value = '';
324  $("#email")[0].value = '';
325  $("#cellphone")[0].value = '';
326  //$("#rfc")[0].value = '';
327  $("#terms")[0].checked = false;
328  $("#username").removeClass('is-invalid');
329  $("#email").removeClass('is-invalid');
330  $("#cellphone").removeClass('is-invalid');
331  //$("#rfc").removeClass('is-invalid');
332  $("#terms").removeClass('is-invalid');
333  isValid = false;
334  grecaptcha.reset();
335}
336
337var submitWithCaptcha = function(token) {
338  if(!isValid) return;
339  var username = $("#username").val().trim();
340  var email = $("#email").val().trim();
341  var cellphone = $("#cellphone").val().trim();
342  //var rfc = $("#rfc").val().trim();
343  $.ajax({
344    url: "includes/register.inclite3.php",
345    method: "POST",
346    data: {
347      username: username,
348      email: email,
349      cellphone: cellphone,
350      //rfc: rfc,
351      timbre:timbres,
352      'g-recaptcha-response': token
353    },
354    success: function(data) {
355      $(".loader").hide();
356      reset();
357      location.href = data;
358    },
359    error: function(data) {
360      grecaptcha.reset();
361      $(".loader").hide();
362    }
363  });
364}
365
366function validaemail() {
367  $(".loader").hide();
368  var regla = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
369
370  if (regla.test($("#correo").val()) == true) {
371    $("#correo").removeClass("is-invalid");
372    b = 0;
373  } else {
374    notifica("El correo no es correcto");
375    $("#correo").addClass("is-invalid");
376    b = 1;
377    grecaptcha.reset();
378  }
379  $(".loader").hide();
380}
381
382function verifica_telefono2() {
383  $("#telefono").removeClass("is-invalid");
384  numero1 = $("#telefono").val().length;
385  if (!isNaN($("#telefono").val())) {
386    if (numero1 != 10) {
387      notifica("Número incorrecto, debe contener 10 dígitos");
388      $("#telefono").addClass("is-invalid");
389      grecaptcha.reset();
390    } else {
391      if ($("#telefono").val() == "") {
392        notifica("Debe ingresar un número telefónico");
393        d = 1;
394      } else {
395        $("#telefono").removeClass("is-invalid");
396        d = 0;
397      }
398    }
399  } else {
400    d = 1;
401    $("#telefono").val("");
402    notifica("Debe ingresar solo números ");
403  }
404}
405
406function valida_nombre() {
407  $("#nombre").removeClass("is-invalid");
408  nombre = $("#nombre").val();
409  if (nombre.length < 2) {
410    $("#nombre").addClass("is-invalid");
411    notifica("Debes Ingresar un Nombre ");
412    grecaptcha.reset();
413  }
414}
415
416function validamensaje() {
417  $("#mensaje").removeClass("is-invalid");
418  mensaje = $("#mensaje").val();
419  if (mensaje == "") {
420    $("#mensaje").addClass("is-invalid");
421    notifica("Debes Ingresar un Nombre ");
422    grecaptcha.reset();
423  }
424}
425
426function validaTerminos() {
427  $("#terminos").removeClass("is-invalid");
428  terminos = $("#terminos").val();
429  if ($("#terminos").is(":checked")) {
430    $("#terminos").removeClass("is-invalid");
431  } else {
432    $("#terminos").addClass("is-invalid");
433    notifica("Debes Aceptar los terminos y condiciones ");
434    grecaptcha.reset();
435  }
436}
437
438function validaTerminos1() {
439  $("#terms").removeClass("is-invalid");
440  terms = $("#terms").val();
441  if ($("#terms").is(":checked")) {
442    $("#terms").removeClass("is-invalid");
443  } else {
444    $("#terms").addClass("is-invalid");
445    notifica("Debes Aceptar los terminos y condiciones ");
446    grecaptcha.reset();
447  }
448}
449
450function enviarEmail() {
451  resp = grecaptcha.getResponse();
452  nombre = $("#nombre").val();
453  correo = $("#correo").val();
454  telefono = $("#telefono").val();
455  mensaje = $("#mensaje").val();
456  terminos = $("#terminos").val();
457  if (
458    nombre.length != "" &&
459    correo.length != "" &&
460    telefono.length != "" &&
461    mensaje.length != "" &&
462    $("#terminos").is(":checked")
463  ) {
464    if (resp.length != 0) {
465      $.ajax({
466        url: "registro/includes/mandaEmail.php",
467        type: "POST",
468        data: {
469          nombre: nombre,
470          correo: correo,
471          telefono: telefono,
472          mensaje: mensaje,
473        },
474        success: function (response) {
475          swal(
476            {
477              title: "Mensaje Enviado",
478              type: "success",
479              confirmButtonText: "ACEPTAR",
480            },
481            function (isConfirm) {
482              if (isConfirm) {
483                $("#nombre").val("");
484                $("#correo").val("");
485                $("#telefono").val("");
486                $("#mensaje").val("");
487                $("#terminos").val("");
488                grecaptcha.reset();
489              }
490            }
491          );
492        },
493      });
494    } else {
495      notifica("Debes Validar reCAPTCHA ");
496    }
497  } else {
498    validamensaje();
499    valida_nombre();
500    verifica_telefono2();
501    validaemail();
502    validaTerminos();
503    grecaptcha.reset();
504  }
505}
506
507function cotiza() {
508  if ($("#cotimbres").val() == 0) {
509    document.getElementById("cantTimbre").innerHTML = "12";
510    document.getElementById("pago").innerHTML = "$175.11";
511  } else if ($("#cotimbres").val() == 0.5) {
512    document.getElementById("cantTimbre").innerHTML = "30";
513    document.getElementById("pago").innerHTML = "$398.11";
514  } else if ($("#cotimbres").val() == 1) {
515    document.getElementById("cantTimbre").innerHTML = "50";
516    document.getElementById("pago").innerHTML = "$482.56";
517  } else if ($("#cotimbres").val() == 1.5) {
518    document.getElementById("cantTimbre").innerHTML = "100";
519    document.getElementById("pago").innerHTML = "$699.48";
520  } else if ($("#cotimbres").val() == 2) {
521    document.getElementById("cantTimbre").innerHTML = "150";
522    document.getElementById("pago").innerHTML = "$939.60";
523  } else if ($("#cotimbres").val() == 2.5) {
524    document.getElementById("cantTimbre").innerHTML = "200";
525    document.getElementById("pago").innerHTML = "$1,108.96";
526  } else if ($("#cotimbres").val() == 3) {
527    document.getElementById("cantTimbre").innerHTML = "500";
528    document.getElementById("pago").innerHTML = "$2,291.00";
529  } else if ($("#cotimbres").val() == 3.5) {
530    document.getElementById("cantTimbre").innerHTML = "1,000";
531    document.getElementById("pago").innerHTML = "$3,735.20";
532  } else if ($("#cotimbres").val() == 4) {
533    document.getElementById("cantTimbre").innerHTML = "2,500";
534    document.getElementById("pago").innerHTML = "$6,322.00";
535  } else if ($("#cotimbres").val() == 4.5) {
536    document.getElementById("cantTimbre").innerHTML = "5,000";
537    document.getElementById("pago").innerHTML = "$9,918.00";
538  }
539}
540
541function cotizahtml() {
542  if ($("#cotimbres").val() == 0) {
543    cantimbre = "12";
544    pago = "$175.11";
545  } else if ($("#cotimbres").val() == 0.5) {
546    cantimbre = "30";
547    pago = "$398.11";
548  } else if ($("#cotimbres").val() == 1) {
549    cantimbre = "50";
550    pago = "$482.56";
551  } else if ($("#cotimbres").val() == 1.5) {
552    cantimbre = "100";
553    pago = "$699.48";
554  } else if ($("#cotimbres").val() == 2) {
555    cantimbre = "150";
556    pago = "$939.60";
557  } else if ($("#cotimbres").val() == 2.5) {
558    cantimbre = "200";
559    pago = "$1,108.96";
560  } else if ($("#cotimbres").val() == 3) {
561    cantimbre = "500";
562    pago = "$2,291.00";
563  } else if ($("#cotimbres").val() == 3.5) {
564    cantimbre = "1,000";
565    pago = "$3,735.20";
566  } else if ($("#cotimbres").val() == 4) {
567    cantimbre = "2,500";
568    pago = "$6,322.00";
569  } else if ($("#cotimbres").val() == 4.5) {
570    cantimbre = "5,000";
571    pago = "$9,918.00";
572  }
573
574  //window.location.href="cotizacion.php?tim="+cantimbre;
575  window.open(
576    "https://api.whatsapp.com/send?phone=+527291502926&text=Paquete de " +
577      cantimbre +
578      " timbres&source=&data=&app_absent=",
579    "_blank"
580  );
581}
582
583function manda_mensaje() {
584  cant = $("#cant").val();
585  nombre = $("#nombre").val();
586  email = $("#email").val();
587  telefono = $("#cellphone").val();
588  resp = grecaptcha.getResponse();
589  if (resp != "") {
590    if (nombre != "" && email != "" && telefono != "") {
591      window.open(
592        "https://api.whatsapp.com/send?phone=+527291502926&text=Paquete de timbres&source=&data=&app_absent=",
593        "_blank"
594      );
595      window.location.href = "index2.html";
596    } else {
597      verifica_nombre();
598      verifica_email();
599      verifica_telefono1();
600    }
601  } else {
602    notifica("Debes Validar reCAPTCHA ");
603  }
604}

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.