이호영 이호영 2025-07-28
친구톡 , 버튼 , 이미지 링크 수정
@b891d82ad19c081114816ec8423b8f769e3fc125
src/main/webapp/WEB-INF/jsp/web/kakao/msgdata/ft/KakaoFriendsTalkMsgDataView.jsp
--- src/main/webapp/WEB-INF/jsp/web/kakao/msgdata/ft/KakaoFriendsTalkMsgDataView.jsp
+++ src/main/webapp/WEB-INF/jsp/web/kakao/msgdata/ft/KakaoFriendsTalkMsgDataView.jsp
@@ -206,13 +206,18 @@
 	$("#imageFileName").val("");	//이미지 파일명 삭제
 	
 }
-
+/* 
 function validateButtons() {
 	var isValid = true;
-	
+
+	console.log($('#buttonAddWrap').html());
+	var val = '';
 	// button_add_wrap 하위 input들 중에서 비어있는 항목이 있는지 확인
 	$('#buttonAddWrap').find('input[type="text"]').each(function() {
-		if ($(this).val().trim() === '') {
+
+		var val = $(this).val().trim();
+		if (val === '') {
+			console.log($(this).prop('outerHTML'));
 			isValid = false;
 			return false; // .each 루프 중단
 		}
@@ -221,9 +226,55 @@
 	if (!isValid) {
 		alert('버튼명 및 링크를 입력해주세요.');
 		return false;
+	}else if (!val.startsWith('http://') && !val.startsWith('https://') ) {
+		alert('버튼의 링크는 http:// 또는 https:// 형식으로 입력해주세요.');
+		$(this).focus();
+		return false;
 	}
 
 	return true;
+} */
+
+function validateButtons() {
+	var isValid = true;
+
+	$('.kakaoBtnNmList').each(function() {
+		var val = $(this).val().trim();
+
+		// 빈 값 체크
+		if (val === '') {
+			alert('버튼명을 모두 입력해주세요.');
+			$(this).focus();
+			isValid = false;
+			return false; // .each 루프 중단
+		}
+	
+	});
+	
+	if(isValid){
+		$('.kakaoBtnList').each(function() {
+			var val = $(this).val().trim();
+	
+			// 빈 값 체크
+			if (val === '') {
+				alert('링크를 모두 입력해주세요.');
+				$(this).focus();
+	 			isValid = false;
+				return false; // .each 루프 중단
+			}
+	
+			// http 형식 체크
+			if (!val.startsWith('http://') && !val.startsWith('https://')) {
+				alert('버튼의 링크는 http:// 또는 https:// 형식으로 입력해주세요.');
+				$(this).focus();
+	 			isValid = false;
+				return false; // .each 루프 중단
+			}
+		});
+	}
+
+
+	return isValid;
 }
 
 //최근 전송내역
@@ -483,14 +534,12 @@
 	//이미지 선택시 링크 정보 및 url 패턴 검사
 	console.log('link: ', link);
 	if (!link) {
-		
-
 		if(!confirm("먼저 URL을 입력하지 않으면 이미지에 URL이 저장되지 않습니다. 계속하시겠습니까?")){
 			return false;	
 		}
-		
-		
-		
+	}else if(!link.startsWith('http://') && !link.startsWith('https://')){
+		alert('이동할 URL은 http:// 또는 https:// 형식으로 입력해주세요.');
+		return false;	
 	}
 	/* 
 	else if(link.search("http://") == -1 && link.search("https://") == -1){
@@ -969,6 +1018,12 @@
 //친구톡 데이터 전송 처리
 function fn_sendMsgData(){
 	
+	// 유효성 검사 실패 시 저장 동작 중단
+/* 	if (!validateLinks()) {
+		return false;
+	}
+	 */
+	
 	var senderKey = $("#selectAgentCode option:checked").val();
 	
 	if(senderKey == ''){
@@ -1341,6 +1396,28 @@
 
 function fn_insertErrorYN(val){
 	$('#errorChk').val(val);
+}
+
+//링크 유효성 검증 함수
+function validateLinks() {
+
+	console.log('검사 대상 수:', $('.kakaoBtnList').length);
+	
+	let isValid = true;
+
+	$('.kakaoBtnList').each(function () {
+		const val = $(this).val().trim();
+
+		console.log('val : ', val);
+		if (val !== '' && !val.startsWith('http://') && !val.startsWith('https://')) {
+			alert(`"${val}" 은(는) http:// 또는 https:// 로 시작해야 합니다.`);
+			$(this).focus();
+			isValid = false;
+			return false; // each 루프 중단
+		}
+	});
+
+	return isValid;
 }
 
 
@@ -2020,7 +2097,7 @@
 										<div class="clearfix receipt_num">
 											<div class="receipt_num_top">
 												<label for="callTo" class="label">받는 번호입력</label>
-												<input type="text" placeholder="번호를 입력하세요" id="callTo" name="callTo" onfocus="this.placeholder=''" onblur="this.placeholder='번호를 입력하세요'" style="width:340px;">
+												<input type="text" value="01012341234" placeholder="번호를 입력하세요" id="callTo" name="callTo" onfocus="this.placeholder=''" onblur="this.placeholder='번호를 입력하세요'" style="width:340px;">
 												<button type="button" class="btnType btnType6 addCallToF">번호추가</button>
 												<span><span class="vMiddle">*</span> 중복번호는 한번만 발송됩니다.</span>
 											</div>
src/main/webapp/publish/js/content.js
--- src/main/webapp/publish/js/content.js
+++ src/main/webapp/publish/js/content.js
@@ -1662,27 +1662,41 @@
 	}
 	var buttonText;
 	var buttonView;
-	//템플릿 버튼은 buttonVO의 buttonVOList 변수에 셋팅해서 넘겨주게 만들었음
+	//템플릿 버튼은 buttonVO의 buttonVOList 변수에 셋팅해서 넘겨주게 만들었음 
 	if (buttonType == "button_type_1") {
-		buttonText = '<dl class="button_type_wrap type1"><dt>배송조회</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeDeliv" name="buttonVOList[' + buttonCnt + '].linkType" value="DS"/><input type="text" id="btnNmDeliv" name="buttonVOList[' + buttonCnt + '].name" value="배송조회" placeholder="버튼명 입력(최대 14자)" readonly><p class="cf_text">*이용가능 택배사 : KG로지스, 우체국택배,일양로지스, GTX로지스, FedEx, 경동택배, 합동택배, 롯데택배</p></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
+		buttonText = '<dl class="button_type_wrap type1"><dt>배송조회</dt><dd class="button_type_input">'
+				+'<input type="hidden" id="buttonLikeTypeDeliv" name="buttonVOList[' + buttonCnt + '].linkType" value="DS"/>'
+				+'<input type="text" id="btnNmDeliv" name="buttonVOList[' + buttonCnt + '].name" value="배송조회" placeholder="버튼명 입력(최대 14자)" readonly><p class="cf_text">*이용가능 택배사 : KG로지스, 우체국택배,일양로지스, GTX로지스, FedEx, 경동택배, 합동택배, 롯데택배</p></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
 		buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewDS">배송조회</button>';
 	} else if (buttonType == "button_type_2") {
-		buttonText = '<dl class="button_type_wrap type2"><dt>웹링크</dt><dd class="button_type_input"><ul><li><input type="hidden" id="buttonLikeTypeWeb" name="buttonVOList[' + buttonCnt + '].linkType" value="WL"/><input type="text" id="btnNmWeb" name="buttonVOList[' + buttonCnt + '].name" value="" maxlength="14" placeholder="버튼명 입력(최대 14자)"></li><li><input type="text" id="buttonLinkMo" name="buttonVOList[' + buttonCnt + '].linkMo" value="" placeholder="모바일 링크 입력"></li><li><input type="text" id="buttonLinkPc" name="buttonVOList[' + buttonCnt + '].linkPc" value="" placeholder="PC 링크 입력"></li></ul></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
+		buttonText = '<dl class="button_type_wrap type2"><dt>웹링크</dt><dd class="button_type_input">		'
+				+'<ul><li><input type="hidden" id="buttonLikeTypeWeb" name="buttonVOList[' + buttonCnt + '].linkType" value="WL"/>'
+				+'<input type="text" class="kakaoBtnNmList" id="btnNmWeb" name="buttonVOList[' + buttonCnt + '].name" value="" maxlength="14" placeholder="버튼명 입력(최대 14자)"></li>'
+				+'<li><input type="text" class="kakaoBtnList" id="buttonLinkMo" name="buttonVOList[' + buttonCnt + '].linkMo" value="" placeholder="모바일 링크 입력"></li>'
+				+'<li><input type="text" class="kakaoBtnList" id="buttonLinkPc" name="buttonVOList[' + buttonCnt + '].linkPc" value="" placeholder="PC 링크 입력"></li></ul></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
 		buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewWL">웹링크</button>';
 	} else if (buttonType == "button_type_3") {
-		buttonText = '<dl class="button_type_wrap type3"><dt>앱링크</dt><dd class="button_type_input"><ul><li><input type="hidden" id="buttonLikeTypeApp" name="buttonVOList[' + buttonCnt + '].linkType" value="AL"/><input type="text" id="btnNmApp" name="buttonVOList[' + buttonCnt + '].name" value="" maxlength="14" placeholder="버튼명 입력(최대 14자)"></li><li><input type="text" id="buttonLinkAnd" name="buttonVOList[' + buttonCnt + '].linkAnd" value="" placeholder="Android 링크 입력"></li><li><input type="text" id="buttonLinkIos" name="buttonVOList[' + buttonCnt + '].linkIos" value="" placeholder="IOS 링크 입력"></li></ul></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
+		buttonText = '<dl class="button_type_wrap type3"><dt>앱링크</dt><dd class="button_type_input">'
+				+'<ul><li><input type="hidden" id="buttonLikeTypeApp" name="buttonVOList[' + buttonCnt + '].linkType" value="AL"/>'
+				+'<input type="text" class="kakaoBtnNmList" id="btnNmApp" name="buttonVOList[' + buttonCnt + '].name" value="" maxlength="14" placeholder="버튼명 입력(최대 14자)"></li>'
+				+'<li><input type="text" class="kakaoBtnList" id="buttonLinkAnd" name="buttonVOList[' + buttonCnt + '].linkAnd" value="" placeholder="Android 링크 입력"></li>	'
+				+'<li><input type="text" class="kakaoBtnList" id="buttonLinkIos" name="buttonVOList[' + buttonCnt + '].linkIos" value="" placeholder="IOS 링크 입력"></li></ul></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
 		buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewAL">앱링크</button>';
 	} else if (buttonType == "button_type_4") {
-		buttonText = '<dl class="button_type_wrap type4"><dt>봇키워드</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeBot" name="buttonVOList[' + buttonCnt + '].linkType" value="BK"/><input type="text" id="btnNmBot" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
+		buttonText = '<dl class="button_type_wrap type4"><dt>봇키워드</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeBot" name="buttonVOList[' + buttonCnt + '].linkType" value="BK"/>'
+				+'<input type="text" id="btnNmBot" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
 		buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewBK">봇키워드</button>';
 	} else if (buttonType == "button_type_5") {
-		buttonText = '<dl class="button_type_wrap type5"><dt>메시지전달</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeMsg" name="buttonVOList[' + buttonCnt + '].linkType" value="MD"/><input type="text" id="btnNmMsg" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
+		buttonText = '<dl class="button_type_wrap type5"><dt>메시지전달</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeMsg" name="buttonVOList[' + buttonCnt + '].linkType" value="MD"/>'
+				+'<input type="text" id="btnNmMsg" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
 		buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewMD">메시지전달</button>';
 	} else if (buttonType == "button_type_6") {
-		buttonText = '<dl class="button_type_wrap type6"><dt>상담톡전환</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeCons" name="buttonVOList[' + buttonCnt + '].linkType" value="BC"/><input type="text" id="btnNmCons" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
+		buttonText = '<dl class="button_type_wrap type6"><dt>상담톡전환</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeCons" name="buttonVOList[' + buttonCnt + '].linkType" value="BC"/>'
+				+'<input type="text" id="btnNmCons" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
 		buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewBC">상담톡전환</button>';
 	} else if (buttonType == "button_type_7") {
-		buttonText = '<dl class="button_type_wrap type7"><dt>챗봇전환</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeBotChg" name="buttonVOList[' + buttonCnt + '].linkType" value="BT"/><input type="text" id="btnNmBotChg" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
+		buttonText = '<dl class="button_type_wrap type7"><dt>챗봇전환</dt><dd class="button_type_input"><input type="hidden" id="buttonLikeTypeBotChg" name="buttonVOList[' + buttonCnt + '].linkType" value="BT"/>'
+				+'<input type="text" id="btnNmBotChg" name="buttonVOList[' + buttonCnt + '].name" value="" placeholder="버튼명 입력(최대 14자)"></dd><dd><button type="button" class="btn_del" onclick="buttonTypeDel(this);"><img src="/publish/images/btn_delete.png" alt=""></button></dd></dl>';
 		buttonView = '<button type="button" class="btn_kakao_type btnEmpty" id="btnViewBT">챗봇전환</button>';
 	} else {}
 	$(".button_add_wrap").prepend(buttonText);
Add a comment
List