diff --git a/UniversityProvider/wwwroot/js/student/student-create.js b/UniversityProvider/wwwroot/js/student/student-create.js index d1aae4d..3d8fc09 100644 --- a/UniversityProvider/wwwroot/js/student/student-create.js +++ b/UniversityProvider/wwwroot/js/student/student-create.js @@ -39,7 +39,11 @@ const validate = () => { errorP.innerHTML = "Заполните поле 'Дата рождения'"; return false } - + if (studCardInput.value === "") { + errorDivShell.style.gridTemplateRows = "1fr"; + errorP.innerHTML = "Заполните поле 'Номер студенческого билета'"; + return false + } students.forEach((student) => { if (student.studentCard === parseInt(studCardInput.value)) { errorDivShell.style.gridTemplateRows = "1fr"; diff --git a/UniversityProvider/wwwroot/js/student/student-update.js b/UniversityProvider/wwwroot/js/student/student-update.js index 62900f8..953e8a3 100644 --- a/UniversityProvider/wwwroot/js/student/student-update.js +++ b/UniversityProvider/wwwroot/js/student/student-update.js @@ -10,12 +10,13 @@ const errorDivShell = document.getElementById("error-div-shell"); students = [] window.addEventListener("load", () => { - const studentsResponse = $.ajax({ - url: `/student/getallbyuser`, + $.ajax({ + url: "/student/getallbyuser", type: "GET", contentType: "json" + }).done((result) => { + students = result; }); - students = studentsResponse; }) const correctData = () => { @@ -40,11 +41,15 @@ const validate = () => { errorP.innerHTML = "Заполните поле 'Дата рождения'"; return false } - + if (studCardInput.value === "") { + errorDivShell.style.gridTemplateRows = "1fr"; + errorP.innerHTML = "Заполните поле 'Номер студенческого билета'"; + return false + } students.forEach((student) => { if (student.studentCard === parseInt(studCardInput.value)) { errorDivShell.style.gridTemplateRows = "1fr"; - errorP.innerHTML = "Заполните поле 'Дата рождения'"; + errorP.innerHTML = "Заполните поле 'Номер студенческого билета' правильными данными, возможно пользователь с таким номером уже есть"; validStudentCard = false; } });