Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

276
Views
Javascript / JQuery how to loop through all html elements with attribute aria-invalid

I have some dynamically ajax generated form:

<form id="formThatWillBeReplcaedViaAjax">

  <div class="col-main">

    <div class="row">
       <div class="input-group">
         <input id="some_unique_generated_id_27362"  aria-invalid="false" ... >
       </div>
    </div>

    <div class="row">
       <div class="input-group">
         <input id="some_unique_generated_id_27363"  aria-invalid="false" ... >
       </div>
    </div>

    <div class="row">
       <div class="input-group">
         <input id="some_unique_generated_id_27364"  aria-invalid="false" ... >
       </div>
    </div>

   </div>

</form>

I have some animation function (loader() ) and the function that replaces the current form with the next form ( requestNextForm() )

I want to check by looping through form with pure JS or JQuery to check if all attributes aria-invalid are equal to "false".

If they are, then let the loader() load the animation and only then request the next form via requestNextForm().

How can I do it with JQuery or JS or maybe Lodash ?

Thank you in advance!

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

  • get all inputs with the attribute aria-invalid whose value is not "false" using querySelectorAll
  • usr the selector 'input[aria-invalid]:not([aria-invalid="false"])' which translates to: return all input elements that have an attribute aria-invalid whose value is not "false"
  • if the above query returns any matches, you know that not all inputs with aria-invalid are "false"

Here's what the code could look like:

var ariaInvalidNotFalse = document.querySelectorAll('input[aria-invalid]:not([aria-invalid="false"])');

if(ariaInvalidNotFalse.length > 0){
  // Some elements have aria-invalid
  // but with a value that is not false
} else {
  // All inputs with aria-invalid 
  // have it set to "false"
  // Call loader() etc...
}
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!