feat: add form validation for inovasi, lingkungan, and pendidikan modules
- Added isFormValid() and isHtmlEmpty() helper functions for form validation - Disabled submit buttons when required fields are empty across multiple admin and public pages - Applied consistent validation pattern for creating and editing records - Commented out WhatsApp OTP sending in login route for debugging/testing - Fixed path in NavbarMainMenu tooltip action
This commit is contained in:
@@ -46,6 +46,24 @@ export default function BeasiswaPage() {
|
||||
};
|
||||
};
|
||||
|
||||
// Check if form is valid
|
||||
const isFormValid = () => {
|
||||
return (
|
||||
beasiswaDesa.create.form.namaLengkap?.trim() !== '' &&
|
||||
beasiswaDesa.create.form.nis?.trim() !== '' &&
|
||||
beasiswaDesa.create.form.kelas?.trim() !== '' &&
|
||||
beasiswaDesa.create.form.jenisKelamin?.trim() !== '' &&
|
||||
beasiswaDesa.create.form.alamatDomisili?.trim() !== '' &&
|
||||
beasiswaDesa.create.form.tempatLahir?.trim() !== '' &&
|
||||
beasiswaDesa.create.form.tanggalLahir?.trim() !== '' &&
|
||||
beasiswaDesa.create.form.namaOrtu?.trim() !== '' &&
|
||||
beasiswaDesa.create.form.nik?.trim() !== '' &&
|
||||
beasiswaDesa.create.form.pekerjaanOrtu?.trim() !== '' &&
|
||||
beasiswaDesa.create.form.penghasilan?.trim() !== '' &&
|
||||
beasiswaDesa.create.form.noHp?.trim() !== ''
|
||||
);
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
await beasiswaDesa.create.create();
|
||||
resetForm();
|
||||
@@ -391,6 +409,7 @@ export default function BeasiswaPage() {
|
||||
radius="xl"
|
||||
bg={colors['blue-button']}
|
||||
onClick={handleSubmit}
|
||||
disabled={!isFormValid()}
|
||||
style={{ fontSize: '0.9375rem', fontWeight: 600, lineHeight: 1.4 }}
|
||||
>
|
||||
Kirim
|
||||
|
||||
Reference in New Issue
Block a user