JSFiddle - React, Tailwind, and code Playground

HTML

<form action="listing.php" method="get" id="theForm">
  <input type="text" name="foo" id="foo" class="form_field" />
  <div id="foo_blank">Invalid!</div>

  <button>Submit</button>
</form>

CSS

form div {
  display: none;
}

JavaScript

$('#theForm').submit(function(e) {
  alert('2');

  $('.form_field').each(function(i, obj) {
    if (!this.value) {
      e.preventDefault();
      $('#' + this.id + '_blank').show();
    }
  });

  alert('3');
});