-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
72 lines (66 loc) · 2.63 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const provinsi = document.getElementById("provinsi");
const getProvinsi = async () => {
const response = await fetch("https://ibnux.github.io/data-indonesia/provinsi.json");
const data = await response.json();
return data;
};
const showProvinsi = async () => {
const options = await getProvinsi();
provinsi.value = options[0];
options.forEach((element) => {
const newOption = document.createElement("option");
newOption.value = element.id;
newOption.text = element.nama;
provinsi.appendChild(newOption);
});
};
showProvinsi();
function validate() {
const nama = document.getElementById("nama").value;
const kota = document.getElementById("kota").value;
const alamat = document.getElementById("alamat").value;
const kodePos = document.getElementById("kode-pos").value;
const telepon = document.getElementById("telepon").value;
const email = document.getElementById("email").value;
const sponsor = document.getElementById("sponsor").value;
const namaPerusahaan = document.getElementById("nama-perusahaan").value;
const alamatPerusahaan = document.getElementById("alamat-perusahaan").value;
const namaKontakPersonal = document.getElementById("nama-kontak-personal").value;
const telpPersonal = document.getElementById("telp-personal").value;
const emailPerusahaan = document.getElementById("email-perusahaan").value;
var letterTest = /\d/;
var emailTest = /(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
if (letterTest.test(nama)) {
alert("Nama tidak boleh berupa angka");
} else if (letterTest.test(kota)) {
alert("Kota tidak boleh berupa angka");
} else if (letterTest.test(sponsor)) {
alert("Sponsor tidak boleh berupa angka");
} else if (letterTest.test(namaPerusahaan)) {
alert("Nama Perusahaan tidak boleh berupa angka");
} else if (letterTest.test(namaKontakPersonal)) {
alert("Nama Kontak Personal tidak boleh berupa angka");
} else if (!emailTest.test(email)) {
alert("Isikan format email dengan tepat");
} else if (!emailTest.test(emailPerusahaan)) {
alert("Isikan format email perusahaan dengan tepat");
} else if (
nama == "" ||
kota == "" ||
alamat == "" ||
kodePos == "" ||
telepon == "" ||
email == "" ||
sponsor == "" ||
namaPerusahaan == "" ||
alamatPerusahaan == "" ||
namaKontakPersonal == "" ||
telpPersonal == "" ||
emailPerusahaan == ""
) {
alert("Masih ada kolom yang kosong, isi terlebih dahulu");
} else {
alert("Selamat anda berhasil registrasi");
window.location = "/succed.html";
}
}