mnaufaldillah

main js Tugas 6 PWEB A

Oct 10th, 2021
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function validateForm() {
  2.     var email = document.forms["ptm"]["email"];
  3.     atposition = email.value.atposition("@");
  4.     dotpositon = email.value.lastIndexOf(".");
  5.  
  6.     function notify() {
  7.         alert("Terima Kasih telah mengisi formulir persetujuan kuliah offline.");
  8.     }
  9.  
  10.     if (document.forms["ptm"]["nama"].value == "") {
  11.         alert("Mohon Isi Nama Anda.");
  12.         document.forms["ptm"]["nama"].focus();
  13.         return false;
  14.     }
  15.  
  16.     if (document.forms["ptm"]["nrp"].value == "") {
  17.         alert("Mohon Isi NRP Anda.");
  18.         document.forms["ptm"]["nrp"].focus();
  19.         return false;
  20.     }
  21.  
  22.     if (document.forms["ptm"]["alamat"].value == "") {
  23.         alert("Mohon Isi Alamat Anda.");
  24.         document.forms["ptm"]["alamat"].focus();
  25.         return false;
  26.     }
  27.  
  28.     if (email.value == "" && atposition < 1 || (dotpositon - atposition < 2)) {
  29.         alert("Mohon Masukkan Email Anda dengan benar");
  30.         email.focus();
  31.         return false;
  32.     }
  33.  
  34.     if (document.forms["ptm"]["jurusan"].selectedIndex < 1) {
  35.         alert("Pilih Jurusan Anda");
  36.         document.forms["ptm"]["jurusan"].focus();
  37.         return false;
  38.     }
  39.    
  40.     if (document.forms["ptm"]["vaksin"].selectedIndex < 1) {
  41.         alert("Pilih Status Vaksin Anda");
  42.         document.forms["ptm"]["vaksin"].focus();
  43.         return false;
  44.     }
  45.  
  46.     notify();
  47.  
  48.     return true;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment