How to check if all inputs are not empty with jQuery

Just use:

$("input:empty").length == 0;

If it’s zero, none are empty.

To be a bit smarter though and also filter out items with just spaces in, you could do:

$("input").filter(function () {
    return $.trim($(this).val()).length == 0
}).length == 0;

Leave a Comment