I have this inputs generated with php loop
<input type="text" name="input1" id="input1" class="input">
<input type="text" name="input2" id="input2" class="input">
<input type="text" name="input3" id="input3" class="input">
<input type="text" name="input3" id="input4" class="input">
I have this jQuery Code to check if any input is empty
if ( $('#input1').val() !== '' && $('#input2').val() !== '' && $('#input3').val() !== '' && $('#input4').val() !== '') {
console.log("The inputs are not empty")
}else{
console.log("One or more inputs are empty")
}
The inputs are generated by looping so the number of inputs changes, I want some code like this to do the validation, i tried this one but it did not work
if ( $('.input').val() !== '') {
console.log("The inputs are not empty")
}else{
console.log("One or more inputs are empty")
}
How can I do that? Any help would be appreciated.