if statement - jQuery check if all of selected inputs are empty -


what simplest way test if of selected inputs empty?

i inputs way:

$myinputs = $('.inputstotest'); 

and test single input with:

if ( $.trim($this.val()) == '' ) 

but how test group , return true if empty or false if (at least one) not empty?

try this:

var $myinputs = $('.inputstotest');  var allempty = $myinputs.filter(function () {     return $.trim(this.value) != ''; }).length == 0;  console.log(allempty); 

fiddle demo

( in order test, enter values in html markup, run fiddle again , check in console.)


Comments