Int_Prog/лаб3/lab3/public/scripts/helpers/formValidate.js
2024-01-19 01:24:45 +04:00

14 lines
491 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { form } from "../variables.js";
export function validateModalForm(isEditMode) {
// Проверка всех инпутов
form.root.querySelectorAll('input').forEach(input => {
if (!input.checkValidity()) return false;
});
if (isEditMode) return true;
// Если isEditMode = false, т.е. мы создаём объект, то должны проверить фото
if (form.fieldPhoto && form.fieldPhoto.files.length === 0) return false;
return true;
}