Guest User

Untitled

a guest
Oct 9th, 2021
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function validateForm() {
  2.     if (document.forms["formPendaftaran"]["nama"].value == "") {
  3.         Swal.fire({
  4.             text: 'Nama Tidak Boleh Kosong',
  5.             icon: 'warning',
  6.             confirmButtonColor: '#3085d6',
  7.         });
  8.         document.forms["formPendaftaran"]["nama"].focus();
  9.         return false;
  10.     }
  11.     if (document.forms["formPendaftaran"]["nrp"].value == "") {
  12.         Swal.fire({
  13.             text: 'NRP Tidak Boleh Kosong',
  14.             icon: 'warning',
  15.             confirmButtonColor: '#3085d6',
  16.         });
  17.         document.forms["formPendaftaran"]["nrp"].focus();
  18.         return false;
  19.     }
  20.     if (document.forms["formPendaftaran"]["email"].value == "") {
  21.         Swal.fire({
  22.             text: 'Email Tidak Boleh Kosong',
  23.             icon: 'warning',
  24.             confirmButtonColor: '#3085d6',
  25.         });
  26.         document.forms["formPendaftaran"]["email"].focus();
  27.         return false;
  28.     }
  29.     if (document.forms["formPendaftaran"]["jurusan"].selectedIndex < 1) {
  30.         Swal.fire({
  31.             text: 'Silakan Memilih Jurusan',
  32.             icon: 'warning',
  33.             confirmButtonColor: '#3085d6',
  34.         });
  35.         document.forms["formPendaftaran"]["jurusan"].focus();
  36.         return false;
  37.     }
  38.     if (document.forms["formPendaftaran"]["alamat"].value == "") {
  39.         Swal.fire({
  40.             text: 'Silakan Lengkapi Alamat',
  41.             icon: 'warning',
  42.             confirmButtonColor: '#3085d6',
  43.         });
  44.         document.forms["formPendaftaran"]["alamat"].focus();
  45.         return false;
  46.     }
  47.     if (document.forms["formPendaftaran"]["ket-vaksin"].selectedIndex < 1) {
  48.         Swal.fire({
  49.             text: 'Silakan Memilih Status Vaksinasi',
  50.             icon: 'warning',
  51.             confirmButtonColor: '#3085d6',
  52.         });
  53.         document.forms["formPendaftaran"]["ket-vaksin"].focus();
  54.         return false;
  55.     }
  56.     else if (document.forms["formPendaftaran"]["ket-vaksin"].value == "1") {
  57.         if (document.forms["formPendaftaran"]["jenis-vaksin"].selectedIndex < 1) {
  58.             Swal.fire({
  59.                 text: 'Silakan Memilih Jenis Vaksin',
  60.                 icon: 'warning',
  61.                 confirmButtonColor: '#3085d6',
  62.             });
  63.             document.forms["formPendaftaran"]["jenis-vaksin"].focus();
  64.             return false;
  65.         }
  66.         if (document.forms["formPendaftaran"]["dosis"].value == "") {
  67.             Swal.fire({
  68.                 text: 'Silakan Lengkapi Dosis Vaksinasi',
  69.                 icon: 'warning',
  70.                 confirmButtonColor: '#3085d6',
  71.             });
  72.             document.forms["formPendaftaran"]["dosis"].focus();
  73.             return false;
  74.         }
  75.         if (document.forms["formPendaftaran"]["no-sertif"].value == "") {
  76.             Swal.fire({
  77.                 text: 'Silakan Lengkapi Nomor Sertifikat Vaksinasi',
  78.                 icon: 'warning',
  79.                 confirmButtonColor: '#3085d6',
  80.             });
  81.             document.forms["formPendaftaran"]["no-sertif"].focus();
  82.             return false;
  83.         }
  84.         if (document.forms["formPendaftaran"]["tgl-vaksin"].value == "") {
  85.             Swal.fire({
  86.                 text: 'Silakan Lengkapi Tanggal Vaksinasi',
  87.                 icon: 'warning',
  88.                 confirmButtonColor: '#3085d6',
  89.             });
  90.             document.forms["formPendaftaran"]["tgl-vaksin"].focus();
  91.             return false;
  92.         }
  93.     }
  94.     else if (document.forms["formPendaftaran"]["ket-vaksin"].value == "2") {
  95.         if (document.forms["formPendaftaran"]["alasan-vaksin"].selectedIndex < 1) {
  96.             Swal.fire({
  97.                 text: 'Silakan Memilih Alasan Belum Vaksinasi',
  98.                 icon: 'warning',
  99.                 confirmButtonColor: '#3085d6',
  100.             });
  101.             document.forms["formPendaftaran"]["alasan-vaksin"].focus();
  102.             return false;
  103.         }
  104.         else if (document.forms["formPendaftaran"]["alasan-vaksin"].value == "6") {
  105.             if (document.forms["formPendaftaran"]["alasan-lain"].value == "") {
  106.                 Swal.fire({
  107.                     text: 'Silakan Isi Alasan Belum Vaksinasi',
  108.                     icon: 'warning',
  109.                     confirmButtonColor: '#3085d6',
  110.                 });
  111.                 document.forms["formPendaftaran"]["alasan-lain"].focus();
  112.                 return false;
  113.             }
  114.         }
  115.     }
  116.  
  117.     Swal.fire({
  118.         title: 'Are you sure?',
  119.         text: "You won't be able to revert this!",
  120.         icon: 'warning',
  121.         showCancelButton: true,
  122.         confirmButtonColor: '#3085d6',
  123.         cancelButtonColor: '#d33',
  124.         confirmButtonText: 'Yes, submit it!'
  125.     }).then((result) => {
  126.         if (result.isConfirmed) {
  127.             Swal.fire({
  128.                 title: 'Succes!',
  129.                 text: 'Your data has been submitted.',
  130.                 icon: 'success',
  131.                 confirmButtonColor: '#3085d6'
  132.             });
  133.             document.forms["formPendaftaran"].reset();
  134.             document.getElementById('sudah-vaksin').style.display = 'none';
  135.             document.getElementById('belum-vaksin').style.display = 'none';
  136.         }
  137.     });
  138.     return false;
  139. }
  140.  
  141. function isVaksin() {
  142.     if (document.forms["formPendaftaran"]["ket-vaksin"].value == "0") {
  143.         document.getElementById('sudah-vaksin').style.display = 'none';
  144.         document.getElementById('belum-vaksin').style.display = 'none';
  145.     }
  146.     else if (document.forms["formPendaftaran"]["ket-vaksin"].value == "1") {
  147.         document.getElementById('sudah-vaksin').style.display = 'block';
  148.         document.getElementById('belum-vaksin').style.display = 'none';
  149.     }
  150.     else if (document.forms["formPendaftaran"]["ket-vaksin"].value == "2") {
  151.         document.getElementById('sudah-vaksin').style.display = 'none';
  152.         document.getElementById('belum-vaksin').style.display = 'block';
  153.     }
  154. }
Advertisement
Add Comment
Please, Sign In to add comment