Check one element on last row of a table is not empty using Jquery.

Posted by Cesar Lopez on Stack Overflow See other posts from Stack Overflow or by Cesar Lopez
Published on 2010-05-05T11:23:43Z Indexed on 2010/05/05 11:28 UTC
Read the original article Hit count: 261

Filed under:
|

I have the following function:

 var emptyFields = false;

          function checkNotEmpty(tblName, columns, className){
          emptyFields = false;
          $("."+className+"").each(function() {
          if($.trim($(this).val()) === "" && $(this).is(":visible")){
          emptyFields = true;
          return false; // break out of the each-loop
          }
          });
          if (emptyFields) {
          alert("Please fill in current row before adding a new one.");
          } else {
          AddRow_OnButtonClick(tblName,columns);
          }
          }

Its checking that all elements in the table are not empty before adding a new row, and I only need to check that the last row of the table has at least an element which its not empty and not the whole table.

Any help would be apreciated.

Thanks

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about for-loop