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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:01:06+00:00 2026-05-27T08:01:06+00:00

I am creating a user form. In this I have textbox and a lot

  • 0

I am creating a user form. In this I have textbox and a lot of number of select dropdown.
After submitting I send all the value to database by $_POST. My form is like This:

     <tr>
         <td>Review Employee Id</td>
         <td><input type="text" name="rcode" id="rcode"  class="genInputBox" /></td>
     </tr>
     <tr>
         <td>Quality of Delivery</td>
         <td>
              <select name="qd" id="qd">
                <option value="">Plz Select Ratting </option>
                <option value="5">5</option>
                <option value="4">4</option>
                <option value="3">3</option>
                <option value="2">2</option>
                <option value="1">1</option>
              </select>
         </td>
      </tr>

And more select boxes………

and for select box validtion I am using like this

   var qd = document.product.qd.options[document.product.qd.selectedIndex].value;
       if (qd == "") {
           error_message = error_message + "Please select Rating In domain Knowledge\n";
           error = 1;
       }

I mentioned lot of select boxes in the form. So my question is can I use a single select box validation script for all select boxes?

I use this answer In this manner

var sels = document.product.getElementsByTagName("select");
for (var i=0,n=sels.length;i<n;i++) {
  if (sels[i].selectedIndex<1) {
    alert(sels[i].options[0]); // alerts Plz Select whatever
    sels[i].focus();

  error_message = error_message + "Please select drop down\n";
   error = 1; }
}
   if (error == 1) {
    alert(error_message);
    return false;
    } else {
    return true;
    }

}

but now if a left only 1 single select drop down without check,then its show 10 error message for selectbox.

  • 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-27T08:01:06+00:00Added an answer on May 27, 2026 at 8:01 am

    Like this – plain JS –

    window.onload=function() {
      var form = document.getElementsByTagName("form")[0]; // assuming first form on page
      form.onsubmit=function() {
        var sels = form.getElementsByTagName("select");
        for (var i=0,n=sels.length;i<n;i++) {
          if (sels[i].selectedIndex<1) {
            alert(sels[i].options[0]); // alerts Plz Select whatever
            sels[i].focus();
            return false; // disallow submit
          }
        }
        return true; // allow submission
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have this entity with a lot of attributes. In the input form
I'm currently creating a Login form and have this code: string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
Specifically, I have a form for creating a User . One of the fields
I've created my own signup form and creating the user using the Membership class.
So within my application is a form for creating a new user, with relevant
I am creating a form where a user will register with a struts2 application.
I am creating a Zend Form to allow the user to change the current
When creating scrollable user controls with .NET and WinForms I have repeatedly encountered situations
I'm doing this tutorial: http://www.phpeveryday.com/articles/Zend-Framework-Database-Creating-Input-Form-P494.html We are building a simple input form using POST
I'm creating a registration form on my school project website. I have given a

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.