export const sanitizeInput = (val: string, allowDecimal = false) => { if (val === "") return ""; // 빈 값 허용 // 소숫점 허용 if (allowDecimal) { // 숫자와 점만 허용 let cleaned = val.replace(/[^0-9.]/g, ""); // 소숫점 여러 개일 경우 첫 번째만 유지 const parts = cleaned.split("."); if (parts.length > 2) { cleaned = parts[0] + "." + parts.slice(1).join(""); } return cleaned; } // 정수만 허용 return val.replace(/[^0-9]/g, ""); };