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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:23:54+00:00 2026-05-12T10:23:54+00:00

I’ve got multiple input fields where they have the same class names. I need

  • 0

I’ve got multiple input fields where they have the same class names. I need to check to make sure at least 1 of them isn’t empty. So I’ve got,

$('form[name=expForm]').submit(function(){
 var msg = "";
 var found = false;
 $('.date-mask').each(function(){
  if($(this).val()){
   found = true;
  }
 });

 if (found != true)  {

msg += “Please provide at least 1 date before submitting.\n”;
return false;
}
var calcFnd = false;
$(‘.calc’).each(function(){
if($(this).val()){
calcFnd = true;
}
});

if (calcFnd != true) {
msg += “Please provide at least 1 expense before submitting.\n”;
return false;
}

if(msg != “”){
alert(msg);
return false;
}

 if($('.ttlR27').val()==""){
  var net = $('.ttlR26').val();
  $('.ttlR28').val(net);
 }
 return false;

});

<cfloop from="1" to="#ArrayLen(labels)#" index="r">
<tr>
 <td class="labels <cfif labels[r] EQ "Day of Week:">row1</cfif>"><cfif ArrayIsDefined(labels,r) AND labels[r] NEQ "Open1"><cfif labels[r] EQ "Open"><input type="text" id="descript#r#" name="descript#r#" class="description descript#r#" value="Enter text here" style="width:auto;" /><cfelse>#labels[r]#</cfif></cfif></td>   

 <cfloop from="1" to="7" index="i">
  <td id="Day#i#" class="row#r# col#i#">
   <cfif r EQ 1>#Left(DayOfWeekAsString(i),3)#<cfelse><cfif r EQ 2>
   <input type="text" class="date-mask" name="dates#i#" required="yes" message="Please provide at least 1 date before submitting.">
   <cfelse>
   <input type="text" 
   <cfif labels[r] EQ "Personal Car: Mileage ##"> id="gasamount#i#" <cfelseif labels[r] EQ "Personal Car: Mileage $">id="gasmoney#i#"</cfif><cfif labels[r] EQ "Open">id="open#r#"</cfif><cfif labels[r] EQ "Daily Totals">id="dailytotals#i#"</cfif> class="all <cfif labels[r] EQ "Personal Car: Mileage ##">gasamount <cfelse><cfif labels[r] NEQ "Daily Totals">C#i# </cfif></cfif><cfif labels[r] EQ "Personal Car: Mileage $">gasmoney<cfelse>calc R#r#<cfif labels[r] EQ "Daily Totals"> </cfif></cfif><cfif labels[r] EQ "Daily Totals">ttlC#i#</cfif><cfif labels[r] EQ "Less Advance(if applicable)"> less</cfif><cfif labels[r] EQ "Net Due Employee"> net</cfif><cfif labels[r] EQ "Open"> open</cfif>" 
    <cfif labels[r] EQ "Daily Totals" OR labels[r] EQ "Personal Car: Mileage $" OR labels[r] EQ "Open1">readonly="readonly"</cfif>
    name="<cfif labels[r] NEQ "Personal Car: Mileage ##" AND labels[r] NEQ "Personal Car: Mileage $" AND labels[r] NEQ "Dates:" AND labels[r] NEQ "Open1" AND labels[r] NEQ "Daily Totals">R#r#.C#i#</cfif><cfif labels[r] EQ "Personal Car: Mileage ##">gasamt#i#</cfif><cfif labels[r] EQ "Daily Totals">celltotals#i#</cfif><cfif labels[r] EQ "Personal Car: Mileage $">gastot#i#</cfif>" /></cfif>
      </cfif>
  </td>
 </cfloop>

  <td class="totals<cfif r EQ 1>1</cfif>"><cfif r EQ 1>Total<cfelse><input type="text" <cfif labels[r] EQ "Less Advance(if applicable)">id="less"</cfif><cfif labels[r] EQ "Net Due Employee">id="net"</cfif>id="totals" class="ttlR#r#" name="totals#r#" readonly="readonly" /></cfif></td>


</tr>
</cfloop>

The class names that are being used are: date-mask, for the top row of dates and calc, for the rest of the table.

I only need 1 input to not be empty to allow for a true submission.

Any ideas?

Edit
Here is the link to the live page. What I’m validating here are two different things, but essentially the same function. The first row, the dates. Also, the entire table. If not all, MOSTLY every input has one of the same classes.

  • 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-12T10:23:54+00:00Added an answer on May 12, 2026 at 10:23 am

    @karim79’s code should work. Here, I wrote a proof of concept that it works:

    The script:

    function checkFields() {
        var found = false;
        $('.huh').each(function(){
            if($(this).val()){
                found = true;
                return false;
            }
        });
    
        if (found == true)  {
            alert("at least one field has value");
        } else {
            alert("all fields are empty");
        }
    }
    

    The mark-up

    <input type="text" class="huh" name="limit1" />
    <input type="text" class="huh" name="limit2" />
    <input type="text" class="huh" name="limit3" />
    <input type="text" class="huh" name="limit4" />
    <input type="text" class="huh" name="limit5" />
    <input type="button" name="submit" value="Submit" onclick="checkFields();"/>
    

    Try this code yourself on a clean html and you’ll see that it actually works.

    Edit for the added code: The code is not reaching the alert part because you are already returning false here: msg += “Please provide at least 1 date before submitting.\n”; return false; Don’t return until you’ve shown the alert

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 154k
  • Answers 154k
  • 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 Well, my guess is that activeLayer is null and then… May 12, 2026 at 10:27 am
  • Editorial Team
    Editorial Team added an answer What I was "missing" was the concept of collapsing margins.… May 12, 2026 at 10:27 am
  • Editorial Team
    Editorial Team added an answer Maybe I missed the question, but why not: class MyException(Exception):… May 12, 2026 at 10:27 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

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

Top Members

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.