For some reason, I only have one input checked instead of each one with name=one . Who can tell how to make a check of each input name="one" ?
$(document).ready(function () { var inputRequired = $( "input[name='one']" ); $('button').on('click', function() { if( !inputRequired.val() ) { console.log("Error"); $(this).parent().find("input[name='one']").val("").addClass('error'); } else { console.log("OK!"); } }) }); input { display: flex; margin: 5px; } button { display: flex; margin: 5px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div> <input class="date" type="text" name="one" > <input class="name" type="text" name="one" > <input class="money" type="text" name="one" > <input class="price" type="text" > <button>Click</button> </div>