1. Coffeescript one liner
It's possible, but I don't think it's the cleanest or nicest solution:
any_blank_fields = '' in (field.value for field in $('form input[type="text"]'))
The in
operator checks if the value on the left exists in the array on the right. The loop inside the parenthesis maps the array of jQuery objects into an array of the fields' values.
2. jQuery filter
There are some jQuery specific solutions which may work better, such as using filter
(see this question). Here is the CoffeeScript version:
emptyFields = $('form input[type="text"]').filter -> this.value is ''
This returns an array of all empty fields, you could convert this to a boolean using
!!emptyFields.length # as zero values are falsey
3. CSS Selector
If all of your input elements have value
properties in the HTML, you can use:
anyEmptyFields = $('form input[type="text"][value=""]').length > 0