Suppose I’ve got a set of textboxes of the form:
<input class="member" type="text" name="integrantes[]" />
For validation, I need to make sure all of these textboxes contain a value, and display an error if not.
My current idea is basically to set the value outside, a la:
var oneEmpty = false;
$(".member").each(function() { oneEmpty = oneEmpty || $(this).val() == "" });
if (oneEmpty) { etc }
However, it’s not particularly elegant. Therefore, is there a better way to pull it off?
You can simply filter out all the inputs that are not empty, and check if you have any inputs left: