JSFiddle - React, Tailwind, and code Playground

by nadeemmnn2007

HTML

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>

<table id="tbl">
<tr>
  <td><input type="text" onchange="checkIndex()" id="tb1"></td>
  <td><input type="text" onchange="checkIndex()" id="tb2"></td>
  <td>
<select class="select" onchange="checkIndex()">
        <option value="1">select</option>
        <option value="2">V2</option>
        <option value="3">V3</option>
    </select></td>
    <td><h1  id="status">
    status
    </h1></td>
</tr>
</table>
    <script>function checkIndex(){ 
	var boolTxtBox=false;
		var selectBoxselectedIndex=$(".select")[0].selectedIndex;
//alert(selectBoxselectedIndex);
		if(selectBoxselectedIndex>0){
			 // set the background to green
			
			 var txtboxes =$('#tbl input:text');
			 $.each(txtboxes,function(i,v){ 
			if($(v).val().trim().length>0){
					boolTxtBox=true;
				}
				else{
					boolTxtBox=false;
				}
			 });
			 if(boolTxtBox==true){
				$('#status').css({'color':'green'});
			 }else{
				$('#status').css({'color':'red'});
			 }
		}
		else{
			//set the background to red
			$('#status').css({'color':'red'});
		}
	}</script>

JavaScript

$(document).ready(function() {
checkIndex();
	});