Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 763985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:38:54+00:00 2026-05-14T16:38:54+00:00

I have the following function: var emptyFields = false; function checkNotEmpty(tblName, columns, className){ emptyFields

  • 0

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.

The className its applied to the table. Please notice, that the problem I have its checking the last row and only one element of the row has to have some text in it. (e.g. each row has 5 textboxes at least one textbox need to have some text inside in order to be able to add another row, otherwise, the alert comes up).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:38:54+00:00Added an answer on May 14, 2026 at 4:38 pm

    This should work:

    if ($('.' + className + ' tr:last input:text:visible[value]').length > 0) {
        AddRow_OnButtonClick(tblName,columns);
    } 
    else {
        alert("Please fill in current row before adding a new one.")
    }
    

    This of course assumes the className you’re using is used on the table element.

    Working example:

    <script type="text/javascript">
    $(function(){
        $('#btn').click(function(){
            if ($('.test tr:last input:text:visible[value]').length > 0) {
                alert('SUCCESS - at least 1 value is filled in!');
            } 
            else {
                alert("FAIL - all textboxes on last row are empty.")
            }
        });
    });
    </script>
    
    <table class="test" border="1">
    <tr>
    <td><input type="text" value="filled" /></td>
    <td><input type="text" value="in" /></td>
    </tr>
    <tr>
    <td><input type="text" value="" /></td>
    <td><input type="text" value="" /></td>
    </tr>
    </table>
    
    <input id="btn" type="button" value="Click Me!" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 502k
  • Answers 502k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you are looking to use the SOAP methods from… May 16, 2026 at 2:41 pm
  • Editorial Team
    Editorial Team added an answer Did you try something like this? var fixtures = (from… May 16, 2026 at 2:41 pm
  • Editorial Team
    Editorial Team added an answer No, Dispose is the method to dispose resources not managed… May 16, 2026 at 2:41 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have the following code: $(input[id$=UserField_hiddenSpanData],input[title=Title]).each(function(){ var rb = $('#ctl00_m_g_c6ae303a_6013_4adb_8057_63a214bcfd24_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_ctl00_SelectResult option').length; var val =
Hello i have this following function: ... var model = $(#carModel); .... model.change(validModel); function
I have the following function: var id = 10; var type = Type A;
i have the following function function change() { var input = document.getElementById('pas'); var input2
I have the following anonymous function: (function() { var a = 1; var b
I have the following function: function getLevel(points) { var level = -1 + Math.sqrt(4
Hey, I have the following function: function getPosition() { var cLeft = $('#element').position().left; var
I have the following function: <script type=text/javascript> function changeText(elem){ var oldHTML = document.getElementById(elem).innerHTML; var
I have the following declaration for DNSServiceRegister: function DNSServiceRegister ( var sdRef: TDNSServiceRef; const
I have the following function (worked in IE6 but is broken in IE8) function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.