Hi Guys,, I'm trying to validation more than 19 textbox in ASP.NET Web Form using javascript. I'm using client side validation but not working and then I'm trying to validation using server side validation but not working too. Where is better validation client site or server side validation and Why if using many logical if statement not working. Mybe any another idea, Anny help could be appriciate
This is the modal for input data
C#
Add Data Pinjaman
×
ID Pinjaman
Tanggal Pinjam
ID Anggota
ID Pengaturan
Pinjaman Ke
Jumlah Maksimal Pinjaman
Jumlah Sisa Pinjaman
Set Tanggal Jatuh Tempo
Nama Anggota
Jumlah Saldo (Rp.)
Rp.
Bunga Per Tahun (%)
%
Lama Cicilan (Bulan)
Bulan
Jumlah Pinjaman (Rp.)
Rp.
Jumlah Angsuran Per Bulan (Rp.)
Rp.
Sisa Pinjaman (Rp.)
Rp.
Status Pinjaman
Pilihan
LUNAS
BELUM LUNAS
ID Admin
Nama User
ID Perusahaan
Nama PerusahaanThi is the Validation
C#
$(document).ready(function () {
$("[id*=btnModalAddDataPinjaman]").click(function () {
var tanggal_pinjam = $("[id*=txttanggal_pinjam]").val();
var id_anggota = $("[id*=txtid_anggota]").val();
var nama_anggota = $("[id*=txtnama_anggota]").val();
var bunga_per_tahun = $("[id*=txtbunga_per_tahun]").val();
var lama_cicilan = $("[id*=txtlama_cicilan]").val();
var jumlah_pinjaman = $("[id*=txtjumlah_pinjaman]").val();
var angsuran = $("[id*=txtangsuran]").val();
var sisa_pinjaman = $("[id*=txtsisa_pinjaman]").val();
var DropDownList_txtstatus_pinjaman = $("[id*=DropDownList_txtstatus_pinjaman]").val();
var id_user = $("[id*=txt_add_id_user]").val();
var nama_user = $("[id*=txtnama_user]").val();
var nama_anggota = $("[id*=txtnama_anggota]").val();
var SetTglJatuhTempo = $("[id*=txtSetTglJatuhTempo]").val();
var PinjamanKe = $("[id*=txtPinjamanKe]").val();
var sisa_pinjaman = $("[id*=txtsisa_pinjaman]").val();
var JumlahSisaPinjamanKe = $("[id*=txtJumlahSisaPinjamanKe]").val();
var JumlahMaksimalPinjaman = $("[id*=txtJumlahMaksimalPinjaman]").val();
var saldo = $("[id*=txt_saldo]").val();
var IDPengaturan = $("[id*=txt_CariIDPengaturan]").val();
if (id_pinjaman == "" && tanggal_pinjam == "" && id_anggota == "" && nama_anggota == "" && bunga_per_tahun == "" && lama_cicilan == "" && jumlah_pinjaman == "" && angsuran == "" && sisa_pinjaman == "" && DropDownList_txtstatus_pinjaman == "" && id_user == "" && nama_user == "" && id_perusahaan == "" && nama_perusahaan == "" && nama_anggota == "" && SetTglJatuhTempo == "" && PinjamanKe == "" && sisa_pinjaman == "" && JumlahSisaPinjamanKe == "" && JumlahMaksimalPinjaman == "" && saldo == "" && IDPengaturan == "") {
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
document.getElementById("").style.border = "2px solid red";
document.getElementById("").style.border = "2px solid red";
document.getElementById("").style.border = "2px solid red";
document.getElementById("").style.border = "2px solid red";
document.getElementById("").style.border = "2px solid red";
document.getElementById("").style.border = "2px solid red";
document.getElementById("").style.border = "2px solid red";
document.getElementById("").style.border = "2px solid red";
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
document.getElementById("").style.border = "2px solid red";
document.getElementById("").style.border = "2px solid red";
document.getElementById("").style.border = "2px solid red";
document.getElementById("").style.border = "2px solid red";
document.getElementById("").style.border = "2px solid red";
document.getElementById("").style.border = "2px solid red";
document.getElementById("").style.border = "2px solid red";
document.getElementById("").style.border = "2px solid red";
alert('Tolong dilengkapi seluruh isian data !!!');
return false
}
if (tanggal_pinjam == "") {
alert("Tanggal Pinjaman tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (id_anggota == "") {
alert("ID Anggota tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (nama_anggota == "") {
alert("Nama Anggota tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (bunga_per_tahun == "") {
alert("Bunga per tahun tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (lama_cicilan == "") {
alert("Lama Cicilan tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (jumlah_pinjaman == "") {
alert("Jumlah Pinjaman tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (angsuran == "") {
alert("Angsuran tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (sisa_pinjaman == "") {
alert("Sisa Pinjaman tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (DropDownList_txtstatus_pinjaman == "") {
alert("Status Pinjaman tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (id_user == "") {
alert("ID Admin tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (nama_user == "") {
alert("Nama Admin tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (nama_anggota == "") {
alert("Nama Anggota tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (SetTglJatuhTempo == "") {
alert("Atur Tanggal Jatuh Tempo tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (PinjamanKe == "") {
alert("Pinjaman Ke tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (sisa_pinjaman == "") {
alert("Sisa Pinjaman tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (JumlahSisaPinjamanKe == "") {
alert("Jumlah Sisa Pinjaman Ke tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (JumlahMaksimalPinjaman == "") {
alert("Jumlah Maksimal Pinjaman tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (saldo == "") {
alert("Saldo tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
if (IDPengaturan == "") {
alert("ID Pengaturan tidak boleh kosong !!!");
document.getElementById("").style.border = "2px solid red";
document.getElementById("").focus();
return false
} else {
document.getElementById("").style.border = "";
}
}
});

Sachin SinghRank #66 · 26.2K reputationPosted Jun 20, 2021, 9:52 AM EDT
Tri SetiaRank #4,571 · 337 reputationPosted Jun 20, 2021, 11:50 AM EDT
Tri SetiaRank #4,571 · 337 reputationPosted Jun 20, 2021, 11:55 AM EDT