How to check if an input-array element is filled?

How to check if an input-array element is filled?

Hi everyone,

I've been puzzled for a while now on the following:

I have an inputform with several inputs, all carrying the name 'participant_surname[]'. 

I would like to check if one of those elements is filled or not and take appropriate action. However, only the first element works wonders, but any other changed inputfield is not detected. How should I solve this? 

Any help is much appreciated!


This is currently the Jquery script:

  1.     $("input[name^='participant_surname[]']").keyup(function() {
  2.         tripamount = parseFloat($("input[name='pricetype']").attr("title"));
  3.         totalamount = tripamount;
  4.         number_of_persons = 1;

  5.         $("input[name='participant_surname[]']").each(function() {
  6.             if($.trim($(this).val()).length > 0) {
  7.                 number_of_persons = number_of_persons + 1;
  8.                 totalamount = totalamount + tripamount;
  9.             }
  10.         });
  11.         $("input[name='option_amount[]']").each(function() {
  12.             optionamount = parseFloat($(this).val());
  13.             totalamount = totalamount + tripamount;
  14.         });
  15.         $(".totalpersons").text(number_of_persons);
  16.         $(".totalprice").text(totalamount);
  17.     });