JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="input1" name="input1" class="myInput" value="this is not empty"><br>
<input type="text" id="input2" name="input2" class="myInput" value=""><br>
<select id="input3" name="input3" class="myInput">
<option value="">(Select something)</option>
<option value="is not empty">this is not empty</option>
</select><br><br>
<input type="button" id="submitMe" value="submit">
JavaScript
$('#submitMe').click(function(){
var params = {};
$('.myInput').each(function() {
var value = $.trim($(this).val());
if(value.length>0)
{
alert($(this).attr('name'));
// params[$(this).attr('name')] = value;
}
// Maybe pass params to an ajax call?
/*
$.ajax({
type: "POST",
url: "your-url-here.com",
data: params,
success: success,
dataType: dataType
});
*/
});
});