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

  • Home
  • SEARCH
  • 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 8749619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:43:25+00:00 2026-06-13T12:43:25+00:00

I have the following code… var min_val = [{id:driverDOA,value:date_of_accident},etc etc…];//put validation elements in an

  • 0

I have the following code…

 var min_val = [{"id":"driverDOA","value":date_of_accident},etc etc...];//put validation elements in an array

       for (var i=0;i<min_val.length;i++)//loop through each element if array
        {
            var object = min_val[i];
            if(object.value == "" || object.value == null)//if element is null or empty then execute code
                {
                    document.getElementById(object.id).parentNode.innerHTML += '<div class="prompt accident">*</div>';
                    document.getElementById('accident-tab').innerHTML += '<div class="prompt accident">*</div>';
                    return false;
                }
            else
                {
                    $('.prompt accident').remove();
                                            sendAjaxRequest();
                }
        }

basically,I’m validating a form by storing the elements required in an array. I then loop through the array and check for any empty values. If the user has left a value then an asterisk is shown next to that element and on the tab for that section.

Once the user has filled in all of the marked form elements then the code removes the asterisks and send an Ajax request.

However at the moment once an empty element has been found it displays the asterisk for that and stops.

What i need is for it to loop through the entire array each time and display all asterisks. I have a feeling that this will be remarkably simple but have been unable to find anything or figure it out.

Any help would be appreciated

  • 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-13T12:43:26+00:00Added an answer on June 13, 2026 at 12:43 pm
    var hasError=false;
    for (var i=0;i<min_val.length;i++)//loop through each element if array
            {
                var object = min_val[i];
                if(object.value == "" || object.value == null)//if element is null or empty then execute code
                    {
                        document.getElementById(object.id).parentNode.innerHTML += '<div class="prompt accident">*</div>';
                        document.getElementById('accident-tab').innerHTML += '<div class="prompt accident">*</div>';
                        hasError= true;
                        //return false; // remove this...
                    } else $('.prompt accident').remove();
            }
      if(!hasError) {
           sendAjaxRequest();
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code snippet in c#. var list = new List<string> { a,
I have following code function Model(onChanged) { this.array = new Array(); this.onChanged = onChanged;
I have following code: <?php $select_options = array(); foreach($delivery_options as $option) { $select_options[$option->getDeviceId()] =
I have following code: public abstract class Operand<T> { public T Value { get;
I have following code snipped: ... var tpc = new ThirtPartyClass(); tpc.ExecuteCommand(); tpc.ExecuteCommand(); ...
I have following code var res = from c in model.Data select new object[]
I have following code: Tools::Logger.Log(string(GetLastError()), Error); GetLastError() returns a DWORD a numeric value, but
I have following code. var mysql = require('mysql'); var connection = mysql.createConnection({ host :
I have following code in Generic Handler of Asp.net: var students= Student.GetStudents(); var result
I have following code uses light sensor but not able to display value of

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.