Skip to main content
added 55 characters in body
Source Link

Html

<input type="text" name="test[]" class="test">

How can I check every input has value? This is what I tried but if one the input has value it will not alert the message

Script

var x = new Array();
var message = "";

jQuery("input[name='test[]']").each(function(){
  var y = jQuery(this).val().toLowerCase();
  if(y){
    x.push(y);
  }
});

if(x.length === 0){
  message += "test";"missing";
};

if(message != ""){
  alert(message);
}

EDIT I want to alert if one of input has no value

Html

<input type="text" name="test[]" class="test">

How can I check every input has value? This is what I tried but if one the input has value it will not alert the message

Script

var x = new Array();
var message = "";

jQuery("input[name='test[]']").each(function(){
  var y = jQuery(this).val().toLowerCase();
  if(y){
    x.push(y);
  }
});

if(x.length === 0){
  message += "test";
};

if(message != ""){
  alert(message);
}

Html

<input type="text" name="test[]" class="test">

How can I check every input has value? This is what I tried but if one the input has value it will not alert the message

Script

var x = new Array();
var message = "";

jQuery("input[name='test[]']").each(function(){
  var y = jQuery(this).val().toLowerCase();
  if(y){
    x.push(y);
  }
});

if(x.length === 0){
  message += "missing";
};

if(message != ""){
  alert(message);
}

EDIT I want to alert if one of input has no value

Source Link

check every input has value

Html

<input type="text" name="test[]" class="test">

How can I check every input has value? This is what I tried but if one the input has value it will not alert the message

Script

var x = new Array();
var message = "";

jQuery("input[name='test[]']").each(function(){
  var y = jQuery(this).val().toLowerCase();
  if(y){
    x.push(y);
  }
});

if(x.length === 0){
  message += "test";
};

if(message != ""){
  alert(message);
}