Show image Loading ...
Clear all

Show image Loading button

1 Posts
1 Users
Posts: 25
Eminent Member
Topic starter

welcome everybody
I have a code that works (loading) when I submit the form
But the problem is that if the field is required, it is not executed
that's good
If you finished the required fields and submitted the form, but there is an error message
For example, the description is incomplete or any other message
The message appears and the button is unfortunately working
The button should only work if all conditions are met

The other problem is that this code must be added to every requested page only
Is it possible to convert it into a job so that it works on the entire site, i.e. the Submit button?
This code

  var loading = false;
$("form").on("submit", function() {
  if (loading) {
    return true;
var $window = $("window");
        var $loading = $(".loading");
        var css = {
            "width": $window.width(),
            "height": $window.height(),
            "background-position": "center " + ($window.height() / 2 + document.documentElement.scrollTop) + "px"
  $loading.css("display", "block");
<div class="loading"><img src="'<?php" echo osc_current_web_theme_url('images/11.gif') ; ?>' /></div>

thank you

Posted : 18/03/2021 1:55 pm