JSFiddle - React, Tailwind, and code Playground

by Md Shah

HTML

<form method=post id="myform">
    <input type="text" name="a1">
        <input type="text" name="a2">
            <input type="text" name="a3">
                <input type="text" name="a4">
                    
    
    
    <input type=submit value="Submit">
</form>

JavaScript

$("#myform").submit(function(e){
	e.preventDefault()
	$('input,select', this).each(function(){
		if($(this).val() == "") $(this).remove();
	})
})