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 7879211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:51:09+00:00 2026-06-03T03:51:09+00:00

I have 5 div tags with the same class. Each div tag has a

  • 0

I have 5 div tags with the same class. Each div tag has a textbox and a dropdownlist with numbers.

How can I check if all these div tags’ textboxes and dropdownlists are empty or not and if it is “do something”.

$step is an array with all of my div tags.

var $step = $(".wizard-step2:visible");

My Textbox have a class Comment and my Dropdownlist have a class Grade.

I have coded this so far but its wrong, I dont want it to check on each div tag, I want it to check all of them.

This is the code that is wrong:

var Comment = $step.find(".Comment").val();
var Grade = $step.find(".Grade").val();

for (var i = 0; i < $step.length; i++) {
    if (Comment != null && Grade > 0) { {
        // do this
    }
    } else {
        alert("You must enter both fields");
    }
}

EDIT:

I think that I did not explain my question well, my code works like all of the answers I got on this question. I dont want to make this if statement to check each div tag. I want to be able to check if all of the div tags have any empty fields do something ” else if all the div tags fields are filled do something.

Users are allowed to leave the fields empty, but if all of the div tags fields are filled do something.

I do not want to do a if statement for each div tag, I want to do a if statement if all the div tags have any empty fields or if all are field.

Lets say I have 5 div tags. I have filled 4 of them and when I filled the last one 5 div tags are filled. Here I want this ” do something “, else nothing should happen. I dont want the if statements to be executed on div tag 1, 2, 3, 4 that are filled I want the if statement to happen when the 5th is filled beacuse then all the div tags are filled else nothing should happen

  • 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-06-03T03:51:10+00:00Added an answer on June 3, 2026 at 3:51 am

    Find the filled elements of each class, and use the length of the resulting selections to perform your tests:

    var $step = $(".wizard-step2:visible");
    
    // returns true if the element's value is not null
    function filled() {
        return !!this.value;
    }
    
    // count the number of non-empty elements
    var n_step     = $step.length; 
    var n_comments = $step.find('.Comment').filter(filled).length;
    var n_grades   = $step.find('.Grade'  ).filter(filled).length;
    
    if (n_comments === n_step && n_grades === n_step) {
         // all filled
    } else if (n_comments === 0 && n_grades === 0) {
         // all empty
    } else {
         // mixed - do nothing
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 div tags. Each having no. of textboxes and button. Each textbox
i have 3 div tags of same class, <div class=redc> <p>sdfs</p> </div> <div class=redc>
I have div tag with css class name. div class name is same in
I have a site that has 2 DIV tags, one floats left the other
I have div which has three buttons as, <div id=buttons> <input id=preview class=ButtonStyle type=submit
Basically, what I'm trying to create is a page of div tags, each has
I have a main Div tag with multiple div tags as below. The child
I have a parent div that has a class style with font-size:11px. I want
I have added div tags to text on the same line as I wanted
I have a couple of div tags nested within each other and a few

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.