Index: arms/html/pdServiceVersion/content-container.html =================================================================== diff -u -r86f4a1e3c19ed5e74f9febae730617a6499a7fbf -r636fa63e5f78dbfc2a0d16949d5fbca623b6ed0a --- arms/html/pdServiceVersion/content-container.html (.../content-container.html) (revision 86f4a1e3c19ed5e74f9febae730617a6499a7fbf) +++ arms/html/pdServiceVersion/content-container.html (.../content-container.html) (revision 636fa63e5f78dbfc2a0d16949d5fbca623b6ed0a) @@ -485,7 +485,7 @@
-
@@ -524,9 +525,9 @@ @@ -549,12 +550,15 @@ + data-original-title="Start date is required." + required + pattern="/^\d{4}\/(0[1-9]|1[012])\/(0[1-9]|[12][0-9]|3[01])$/" + />
+ data-original-title="End date is required." + required + pattern="/^\d{4}\/(0[1-9]|1[012])\/(0[1-9]|[12][0-9]|3[01])$/" + />
@@ -671,7 +678,7 @@
@@ -702,11 +712,13 @@
+ placeholder="Product(Service) version" + required + data-original-title="Version is required." + />
@@ -728,12 +740,15 @@ + pattern="/^\d{4}\/(0[1-9]|1[012])\/(0[1-9]|[12][0-9]|3[01])$/" + required + data-original-title="Start date is required." + /> @@ -755,12 +770,15 @@ + pattern="/^\d{4}\/(0[1-9]|1[012])\/(0[1-9]|[12][0-9]|3[01])$/" + required + data-original-title="End date is required." + /> Index: arms/js/pdServiceVersion.js =================================================================== diff -u -r10e69a4b6138e9eba54c8da32664b0a99561616e -r636fa63e5f78dbfc2a0d16949d5fbca623b6ed0a --- arms/js/pdServiceVersion.js (.../pdServiceVersion.js) (revision 10e69a4b6138e9eba54c8da32664b0a99561616e) +++ arms/js/pdServiceVersion.js (.../pdServiceVersion.js) (revision 636fa63e5f78dbfc2a0d16949d5fbca623b6ed0a) @@ -260,6 +260,9 @@ function click_btn_for_update_version() { $("#version_update").click(function () { console.log("update btn"); + if (modalFormValidate() === false) { + return; + } var send_data = { c_id: selectVersion, @@ -292,6 +295,9 @@ //////////////////////////////////////////////////////////////////////////////////////// function modalPopupNewUpdate() { console.log("save btn"); + if (modalFormValidate("") === false) { + return; + } var send_data = { c_id: selectId, @@ -328,6 +334,11 @@ // 버전 팝업 수정 업데이트 //////////////////////////////////////////////////////////////////////////////////////// function modalPopupUpdate() { + console.log("modalPopupUpdate"); + if (modalFormValidate("") === false) { + return; + } + $.ajax({ url: "/auth-user/api/arms/pdServiceVersion/updateNode.do", type: "put", @@ -350,7 +361,66 @@ } }); } +//////////////////////////////////////////////////////////////////////////////////////// +//버전 등록,수정 관련 3가지 케이스에 대한 유효성 검증 +//모달 여부에 따라 form이 정해지고, 해당 form 하위의 required 속성을 가진 input 태그를 모두 체크합니다. +//////////////////////////////////////////////////////////////////////////////////////// +function modalFormValidate(formId) { + console.log("modalFormValidate"); + if(formId === "") { + // 모달 form + return formValidate($('.product-service-version-modal-form').find('input[required]')); + } else { + // 일반 form + return formValidate($('.product-service-version-form').find('input[required]')); + } +} +function formValidate(formInput) { + console.log("formValidate"); + let startDateElement; + let endDateElement; + + for (let i = 0; i < formInput.length; i++) { + let input = $(formInput[i]); + + if (input.hasClass('input_pdservice_start_date')) { + startDateElement = input; + } + + if (input.hasClass('input_pdservice_end_date')) { + endDateElement = input; + } + + if (!input.val().trim()) { + let message = input.data('original-title') || "Some explanation text here"; + alert(message); + input.focus(); + return false; + } + + if (input.hasClass('input_pdservice_version') && !isValidVersion(input.val())) { + alert("The version is invalid. Please use the 0.1 or 0.0.1 format"); + input.focus(); + return false; + } + + } + + const startDate = new Date(startDateElement.val()); + const endDate = new Date(endDateElement.val()); + if (startDate && endDate && startDate > endDate) { + alert("The end date must be the same or after the start date."); + endDateElement.focus(); + return false; + } +} + +function isValidVersion(version) { + const regex = /^(\d+\.\d+(\.\d+)?)$/; + return regex.test(version); +} + //////////////////////////////////////////////////////////////////////////////////////// //버전 리스트를 재로드하는 함수 ( 버전 추가, 갱신, 삭제 시 호출 ) ////////////////////////////////////////////////////////////////////////////////////////