feat: 일축압축시험 중, 시료직경과 시료길이의 최대값 설정 및 소수점 3자리까지만 입력되도록 제한

main
thkim 2024-07-16 15:47:59 +09:00
parent b89ee534f4
commit 8ff2bb54e2
2 changed files with 76 additions and 22 deletions

View File

@ -183,28 +183,6 @@
function extractRadioLabelsByTableHeadText(headText) {
var tableRows = document.getElementsByTagName("tr"); // 모든 tr 요소 가져오기
var labels = [];
for (var i = 0; i < tableRows.length; i++) {
var headCell = tableRows[i].querySelector('.td-head'); // td-head 클래스 찾기
if (headCell && headCell.textContent === headText) { // 텍스트 비교
var radioLabels = tableRows[i].getElementsByTagName("label"); // 하위 label 요소 가져오기
for (var j = 0; j < radioLabels.length; j++) {
var labelText = radioLabels[j].textContent || radioLabels[j].innerText; // IE 호환성
labels.push(labelText); // label 텍스트 배열에 추가
}
break; // "전단탄성계수"를 찾았으므로 반복 종료
}
}
return labels; // label 텍스트 배열 반환
}
function extractRadioLabelsByName(inputName) { function extractRadioLabelsByName(inputName) {
var radios = document.getElementsByName(inputName); // name 속성으로 radio 버튼 가져오기 var radios = document.getElementsByName(inputName); // name 속성으로 radio 버튼 가져오기
var labels = []; var labels = [];

View File

@ -980,7 +980,83 @@ function fn_openClipReport2(table,project,hole,sample,etc1,etc2,gbn){
input.select(); input.select();
}); });
}); });
kendoJQuery(input).on("keyup", function(event) {
var inputElements = document.getElementsByTagName("input"); // 모든 input 요소 가져오기
for (var i = 0; i < inputElements.length; i++) {
var input = inputElements[i];
if (input.className.indexOf("k-input") !== -1) {
var parentDiv = findParentDiv(input); // 상위 div 찾는 함수 호출
if (parentDiv) {
var title1 = parentDiv.innerText;
title1 = title1.replace(/[\r\n]/g, ''); // \\r \\n 제거.
title1 = trimString(title1); // 공백 제거 함수 호출
title1 = title1.toLowerCase(); // 소문자 변환
if( title1 === "시료직경(cm)") {
var inputValue = kendoJQuery(this).val();
restrictInput(input, 1);
} else if( title1 === "시료길이(cm)") {
var inputValue = kendoJQuery(this).val();
restrictInput(input, 2);
} }
}
}
}
});
}
function restrictInput(inputElement, maxIntegerDigits) {
var value = inputElement.value;
// 정규 표현식으로 유효성 검사 (정수부 자릿수 제한 추가)
var regex = new RegExp("^[0-9]{0," + maxIntegerDigits + "}(\\.[0-9]{0,3})?$");
var isValid = regex.test(value);
if (!isValid) {
// 유효하지 않은 값 제거
inputElement.value = value.substring(0, value.length - 1);
}
}
function findParentDiv(element) {
var currentElement = element;
while (currentElement.parentNode) {
currentElement = currentElement.parentNode;
if (currentElement.tagName === "TR" && currentElement.className.indexOf("k-grid-edit-row") !== -1) {
if( currentElement !== null && currentElement.childNodes !== null && 0 < currentElement.childNodes.length ) {
return findChildDivByClass(currentElement.childNodes[0], "td-data");
}
}
}
return null; // 상위 div를 찾지 못한 경우
}
function findChildDivByClass(parentElement, className) {
var children = parentElement.childNodes; // 자식 노드 목록 가져오기
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (child.nodeType === 1 && // 요소 노드인지 확인
child.tagName === "DIV" && // div 태그인지 확인
child.className.indexOf(className) !== -1) { // 클래스명 확인
return child; // 조건에 맞는 요소를 찾으면 반환
}
}
return null; // 조건에 맞는 요소를 찾지 못하면 null 반환
}
function trimString(str) {
return str.replace(/^\s+|\s+$/g, ''); // 문자열 앞뒤 공백 제거
}
function fn_kendoGrid() { function fn_kendoGrid() {
var dataObj = gridData[0]; var dataObj = gridData[0];