JSFiddle - React, Tailwind, and code Playground
HTML
<form data-alert="You must provide:" action="" method="post">
<p><input type="text" data-alert="Your Google Map's mileage" placeholder="mileage" /></p>
<p><input type="text" data-alert="Your business name" placeholder="business name" /></p>
<p><input type="text" placeholder="your email" /></p>
<p><input type="text" placeholder="your credit card number" /></p>
<p><input type="submit" value="Submit" /></p>
</form>
JavaScript
$('form').on('submit', function () {
var thisForm = $(this);
var thisAlert = thisForm.data('alert');
var canSubmit = true;
thisForm.find('[data-alert]').each(function(i) {
var thisInput = $(this);
if ( !$.trim(thisInput.val()) ) {
thisAlert += '\n' + thisInput.data('alert');
canSubmit = false;
};
});
if( !canSubmit ) {
alert( thisAlert );
return false;
}
});