How can I check the Number of Incomplete Input fields in Particular ID, (form1, form2). If 2 input fields are empty, in i want a msg saying something like "Incomplete Input 2" How is it Possible to do this in JS ?
<div id="form1">
<span>Number of Incomplete Input: 2</span>
<input type="text" value="">
<input type="text" value="">
</div>
<div id="form2">
<span>Number of Incomplete Input: 1</span>
<input type="text" value="Test">
<input type="text" value="">
</div>
This is the JS, which is working, i have have multiple JS with class named assigned to each inputs and get the value, but i need to make this check all the Input fields inside just the ID.
$(document).on("click", "#form1", function() {
var count = $('input').filter(function(input){
return $(this).val() == "";
}).length;
alert(count);
});
<form validate><input type="text" required /></form><form>element around them all? i feel there is missing important HTML here we need to know aboutinput:not([value]):not([value=""])which will select all the inputs that has no value attributes or empty one, then check the length