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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:22:32+00:00 2026-05-28T06:22:32+00:00

I need help with a form validator. It validates everything like text and such

  • 0

I need help with a form validator. It validates everything like text and such fine, but I need it to validate whether an unordered list has at least 1 element/item in it.

My initial idea was to count the childNodes in the unordered list, but using .childNodes.length did not work. I’m not sure why, possibly because I have jQuery intermingled in my javascript functions?

Here is an example of the validation function for a text string:

 function checkLength( o, n, min, max ) {
    if ( o.val().length > max || o.val().length < min ) {
         o.addClass( "ui-state-error" );
     updateTips( "Length of " + n + " must be between " +
         min + " and " + max + "." );
     return false;
  } else {
    return true;
       }
 }

Here is what my unordered form validation function was (doesn’t work):

function checkTags( t ) {
if (t.childNodes.length < 1) {
    t.addClass( "ui-state-error" );
    updateTips( "Add at least 1 genre/subgenre." );
    return false;
}
else {
        return true;
}
}

The unordered list is populated by the user, after selecting values from a select list and clicking a javascript link, if that matters. Thanks in advance for any help!

  • 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-28T06:22:32+00:00Added an answer on May 28, 2026 at 6:22 am

    assuming t is a jQuery object, try

    if (!t.children().length) {
        t.addClass('ui-state-error');
    }
    

    here’s a link for your reference: http://api.jquery.com/children/

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

Sidebar

Related Questions

I have little snippet for validatin' my form. I need help to position the
I really need help on this one. I am having a simple login form
I need help understanding some C++ operator overload statements. The class is declared like
I need to validate a bunch of form fields within one element. I just
I need help to automatically select an option to submit with a form: When
I'm using this jQuery Validation script to submit my form(s), but I need some
I have a form like so. <form name=theform id=theform> <input type=text name=name> <input type=submit
Am pretty new to ROR. Need help in Rails form validation. Am using rails
I have this regular expression to help me validate a form input. var nrExp
I have a form where I need to validate DateFrom and DateTo. I have

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.