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

339
Views
Stop CSS loader spinning if form validation error, django, javascript

How do I stop the loader spinner showing if the form submit fails and the user has to complete a missing form field. The spinner keeps spinning forever while the user enters the missing information.

My submit button in the form:

...
  <div class="control">
    <button type="submit" class="button" onclick="showDiv()">Submit
    </button>
  </div>
</form>

My spinning loader below the form:

<span class="loader" id="loadingdisplay" style="display:none;"></span>

My javascript on click event to display spinning loader:

<script type="text/javascript">

        function showDiv() {
           document.getElementById('loadingdisplay').style.display = "block";
        }

</script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can add a listener on your form or your field that will hide your loader.

<script>
var x = document.getElementById("myInputField");
x.addEventListener("focus", myFunctionHideDiv);


function myFunctionHideDiv() {
  document.getElementById('loadingdisplay').style.display = "None";
}
</script>

Ressources :

  • EventListener documentation
  • Event documentation
about 4 years ago · Juan Pablo Isaza 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!