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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:23:09+00:00 2026-05-16T08:23:09+00:00

I am validating some fields and check if the length of a select element

  • 0

I am validating some fields and check if the length of a select element is larger than 0. I get the error “‘length’ is null or not an object” because id$=SelectResult is a listbox and can have no values and therefor return null and var val = $(this).val(); doesn’t like that.

function checkControls() {
  var itemLevel = $("select[title='Item Level']").val();
  switch (itemLevel) {
    case 'Strategic Objective':

 var controlsPassed = 0;


    $("input[id$=UserField_hiddenSpanData],input[title=Title],select[id$=SelectResult]").each(function(){


        var val = $(this).val();
        if(val != 0 && val.length != 0) { 

            //add one to the counter
            controlsPassed += 1;
        }

        });
return (controlsPassed == 3) 

    case 'Milestone Action':

      var controlsPassed = 0;


    $("input[title=Target Date],select[id$=SelectResult],input[title=Title],input[id$=UserField_hiddenSpanData],input[title=Start Date],select[title=Strategic 

Objective],select[title=Strategic Priority]").each(function(){


        var val = $(this).val();
        if(val != 0 && val.length != 0) { 

            //add one to the counter
            controlsPassed += 1;
        }

        });
return (controlsPassed == 7) 

case 'Performance Measure':

      var controlsPassed = 0;


    $("select[title=Strategic Objective],input[title=Title],select[id$=SelectResult],select[title=Strategic Priority]").each(function(){

        var val = $(this).val();
        if(val != 0 && val.length != 0) { 

            //add one to the counter
            controlsPassed += 1;
        }

        });
return (controlsPassed == 4) 


    case 'Strategic Priority':

      var controlsPassed = 0;


    $("input[title=Target Date],select[id$=SelectResult],input[title=Title],input[id$=UserField_hiddenSpanData],input[title=Start Date],select[title=Strategic 

Objective]").each(function(){   

        //var ResponsibleBusiness = $("select[id$=SelectResult]").val();
        var val = $(this).val();
        if(val != 0 && val.length != 0) { 

            //add one to the counter
            controlsPassed += 1;
        }

        });
return (controlsPassed == 6) 
  }
}

function PreSaveItem() {
            return checkControls()
    }
  • 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-16T08:23:11+00:00Added an answer on May 16, 2026 at 8:23 am

    If I’m understanding your goal correctly, you can shorten it down to this:

    if(!$("select[id$=SelectResult]").val()) return false;
    return $("input[title=Target Date],input[title=Title],input[id$=UserField_hiddenSpanData],input[title=Start Date],select[title=Strategic Objective]").filter(function(){
             return $(this).val() == '';
           }).length > 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am validating a form for empty check. All fields works fine. I have a
There are some text fields in my Sproutcore code. However, I need to check
I'm having some problem with validations for multiple fields, specifically with case-sensitive unique validations
I'll admit, I'm an XML newbie. I'm having trouble validating some xml against a
I've setup some Nunit tests for validating my statistical formulas within my .net v2
I am validating XML documents against a schema. Some more complex documents/schemas always fail
The HTML5 spec defines some very interesting validation components, including pattern (for validating against
For some reason my form is not checking the database to see if the
I have started putting some validation in the text fields. There must be an
I have a simple JSF+RichFaces form with some fields and obviously a backing bean

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.