팁/튜토리얼

마켓플레이스 글등록 체크

2019.02.13 08:24
1,105
0
0

마켓플레이스 스킨에서 글쓰기 버튼을 클릭했는데 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();" />
eond Lv. 12

댓글 0