마켓플레이스 스킨에서 글쓰기 버튼을 클릭했는데 2번 등록되신다고 2번 클릭시 경고창 뜨는 소스입니다.

 

click_flag = 0; // 글등록 초기값
// console.log('클릭플래그는'+click_flag+'입니다');

check_cat = 0; // 카테고리값 초기값
var cat_sub = jQuery("#cat").siblings("select");
jQuery(cat_sub).on('change', function() {
   check_cat = 1; // 카테고리값 선택값
});

// 썸네일
check_thumb = 0;
var thumb = jQuery("input[name='thumbnail[0]']");
jQuery(thumb).on('click', function() {
   check_thumb = 1;
});

// 에디터
check_editor = 0;
// jQuery("#cke_editor1").on('click', function() {
jQuery(".cke_reset").on('click', function() {
   jQuery(this).addClass("asdf");
   check_editor = 1;
   console.log('editor='+check_editor);
});
// jQuery("#cke_editor1").hasClass("cke_focus")

function inputCheck(){
   // 썸네일 체크
   if( check_thumb=='0' ){
      console.log('a'+check_thumb);
      return true;
   } else{
      console.log('+a'+check_thumb);
   }
   // 카테고리 체크
   if( check_cat=='0' ){
      console.log('b'+check_cat);
      return true;
   } else {
      console.log('+b'+check_cat);
   }

   // 판매가격 체크
   var c = jQuery("#item_price").val().length;
   if( !jQuery("#item_price").val().length ){
      console.log('c'+c);
      return true;
   } else{
      console.log('+c'+c);
   }
   // 상품명 체크
   if( jQuery("#title").val().length == '0' ){
      console.log('d'+jQuery("#title").val().length);
      return true;
   } else{
      console.log('+d'+jQuery("#title").val().length);
   }
   // 검색태그 체크
   if( jQuery("#item_name").val().length == '0' ){
      console.log('e'+jQuery("#item_name").val().length);
      return true;
   } else{
      console.log('+e'+jQuery("#item_name").val().length);
   }
   // 전화번호 체크
   if( jQuery("input[name='extra_vars2']").val().length == '0' ){
      console.log('f'+jQuery("input[name='extra_vars2']").val().length);
      return true;
   } else{
      console.log('+f'+jQuery("input[name='extra_vars2']").val().length);
   }
   // 에디터 체크
   // if( check_editor=='0' ){
   //     console.log('g'+check_editor);
   //     return true;
   // } else {
   //     console.log('+g'+check_editor);
   // }

   // 동의확인 체크
   if( jQuery("input[name='extra_vars4']").val().length == '0' ){
      console.log('h'+jQuery("input[name='extra_vars4']").val().length);
      return true;
   } else{
      console.log('+h'+jQuery("input[name='extra_vars4']").val().length);
   }

   click_flag++;
   console.log('i'+click_flag);

   if(click_flag > 0 ){
      alert("이미 클릭했습니다.");
      $('input[type=submit]').attr('disabled', true);
   }
}

서브밋 버튼에는 다음 코드를 추가해줍니다.

<input type="submit" style="text-align:center; width:200px; height:100px; value="{$lang->cmd_registration}" class="btn" onclick="return inputCheck();" />

이온디

profile
이온디는 라이믹스를 비롯한 다양한 CMS의 시드뱅크를 꿈꿉니다. 여러분들이 사랑하는 웹소스를 언제든지 사용할 수 있게 하기 위해 이온디는 매일 소스코드를 유지보수하고 있으며, 언제든지 다운로드할 수 있는 소스마켓을 운영하고 있습니다.

#XE마켓 - 이온디스토어
https://eond.com/xemarket/

# XE/라이믹스 단톡방을 운영 중입니다. (비번: 2022)
https://open.kakao.com/o/giaKKnl

# XE/라이믹스 생활코딩 모듈 강좌입니다.
https://opentutorials.org/module/3774