멍청멍청기록

제이쿼리 JQuery] 테이블의 컬럼 값을 이용한 Validation Check

  • -
728x90
반응형
<div class="dataTables_wrapper form-inline dt-bootstrap no-footer">
	<table id="tblChannelTreatHistory" class="table table-striped table-nowrap table-bordered" cellspacing="0" width="100%">
		<thead>
			<tr>
				<th>채널 티켓(쿠폰)번호</th>
				<th>금액</th>
				<th>사용처리일자</th>
			</tr>
		</thead>
		<tbody>
		</tbody>
	</table>
</div>
var tableValue1 = $('#tblChannelTreatHistory tbody tr:eq(1)>td:eq(0)').html();

위의 형식으로 테이블을 접근하고 그 테이블의 tr td 의 N번째 컬럼에 접근할 수 있다.

	function UseComparisonValidationCheck() {
	  var tableValue1 = $('#tblChannelTreatHistory tbody tr:eq(1)>td:eq(0)').html();
	  var tableValue2 = $('#tblTcmUseTreatHistory tbody tr:eq(1)>td:eq(0)').html();
	   if(tableValue1 == '' || tableValue1 == undefined) {
	     alert('업로드할 파일을 선택해주세요.');
	     return false;
	   }
	   if(tableValue2 == '' || tableValue2 == undefined) {
	     alert('TCM사용처리내역 조회를 해주세요.');
	     return false;
	   }
	   
	     return true;
	}

아래와 같이 함수를 만들어서 사용할 수 있다.

반응형
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.