JSFiddle - React, Tailwind, and code Playground

by Shree Khanal

HTML

<input type="text" name="text1" id="text1">
<input type="text" name="text2" id="text2">
<input type="text" name="text3" id="text3">
<input type="text" name="text4" id="text4">
<input type="button" id="btnTest">

JavaScript

$("#btnTest").click(function() {
  $('input[type=text]').each(function() {
    var msg = $(this).prop("id");
    if ($(this).val() == "") {
      switch (msg) {
        case ("text1"):
          alert('miss 1');
          break;
        case ("text2"):
          alert('miss 2');
          break;
      }
    }

  })
});