JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<input type="text" /><br />
<input type="text" /><br />
<input type="text" /><br />
<input type="submit" value="next" class="next" />
</div>
<div>
<input type="text" /><br />
<input type="text" /><br />
<input type="text" /><br />
<input type="submit" value="next" class="next" />
</div>
<div>
<input type="text" /><br />
<input type="text" /><br />
<input type="submit" value="next" class="next" />
</div>
JavaScript
$('.next').click(function() {
var missingRequired = $(this).closest('div')
.find('input[value=""]');
if (missingRequired.length) {
alert('there were required fields that were not completed');
}
});