JSFiddle - React, Tailwind, and code Playground
HTML
<select name="test" id="select" onchange="selection()">
<option value="">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="nil">nil</option>
</select>
<td>test</td>
<td><input type="text" name="test1" id="test1" />
<input type="button" value="submit" onclick="selection()" />
JavaScript
function selection()
{
var cat = document.getElementById('select').value;
if (cat == "B") {
if (document.getElementById("test1").value == "") {
alert('Mandatory');
return false;
}
}
return true;
}