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>
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 :