I want to ask if there\'s a better way in jQuery to select multiple text input then check if any of them has a value. Here\'s my code:
if ($(\"#reference\")
How about:
http://jsfiddle.net/lollero/rr2ss/1/
Another example: http://jsfiddle.net/lollero/rr2ss/12/
$(function() {
// Check value of each and every input element....
// Which you can of course change to be more specific, like: $('#myForm input')
$( "input" ).val(function( i, val ) {
// Return the console log IF value is not empty
// value=" " still counts as "not empty", because technically it isn't
// You could of course replace the console.log(); with anything you'd like
val && console.log('not empty: input-' + (++i) );
// Note that you don't have to return val if you don't want to, it's just for show in this case.
return val
});
});