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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:07:56+00:00 2026-06-03T06:07:56+00:00

I have the following validation code, which properly highlights all problem areas in my

  • 0

I have the following validation code, which properly highlights all problem areas in my form IF the FIRST text-input or menu is left empty.

However, if you fill in the first text input and choose from the first select box, this validation lets you pass, incorrectly.

I’ve included my jquery for searching for empty text fields and select menus.. but if I need to paste the whole thing let me know.

// create error flag
var error = 0;

// check required text fields for empty values, add class 'problem' to cells with inputs that have problems
if (!$('#register-form .required input').val()) {
    $('.required input:text[value=""]').parent().addClass("problem");
    error++;
    console.log('errors: ' + error + '; required text input missing a value.')
}

// check required select menus for default selections, add class 'problem' to cells with select menus that have problems
if (!$('#register-form .required select option:selected').val()) {
    $('.required select option:selected[value=""]').parent().parent().addClass("problem");
    error++;
    console.log('errors: ' + error + '; required select box missing a value.')
}

but this validation fails if I satisfy (only) the first text input or select menu out of a set of required.

I obviously need this validation to check EVERY text input and every inside of a cell with class .required

  • 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-03T06:07:57+00:00Added an answer on June 3, 2026 at 6:07 am
    $('#register-form .required').each(function() {
    
      var $input = $('input[type="text"]', this),
          $select = $('select', this);
    
      if(!$.trim($input.val())) {
         $input.parent().addClass("problem");
          error++;
          console.log('errors: ' + error + '; required text input missing a value.')
    
      }
    
      if(!$select.val()) {
          $select.parent().parent().addClass("problem");
          error++;
          console.log('errors: ' + error + '; required select box missing a value.'
      }
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code, which works nicely: $('#register form .submit input').click(function(){ if(jQuery.trim($('#new-usr').val()) ==
I have the following validation code for a text field but the 'field' below
I have the following code validation php script: if(empty($_POST['captcha_code'])) { $error = 1; $code[3]
I have been following the validation for Entry boxes from here . The code
I have the following code to enable validation work: $(document).ready(function() { $(#eventForm).validate({ rules: {
I have the following code block for validation in PHP and I can't figure
I have the following, which doesn't work, my validation seems that it's not triggered
I have a form on which I use validation. This form has a section
I have the following code which works perfect in IE for a textarea element.
I have the following problem: I need to validate data in a controller, which

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.