I have an HTML form which submits to another page via POST. Nothing special about it, except that after the form validates I try to hide and/or disable the submit button so that it cannot be double-submit, while also telling the user the next page might take a while to load.
The relevant code is:
jQuery(document).ready(function () { jQuery("form#form").submit(function() { var result = validate(); jQuery(this).find('input[type=submit]').prop('disabled', true); jQuery("#submit-button-wrapper").html(jQuery("#submit-button-wrapper").html()+ "<br/><br/><span style='margin: 25px; padding: 5px; background: yellow; "+ "width: 100%; font-weight: bold;'>Loading... this may take a few minutes! "+ "<i class='fa fa-spinner fa-spin' style='color: blue;'></i></span>"); return result; }); }); function validate() { return true; // Does stuff, then returns a simple true or false } By request, here is the (very simple) button wrapper HTML:
<div class="col-sm-12" id="submit-button-wrapper"> <input type="submit" value="One More Step" /> </div> When the I remove the which changes the button wrapper's HTML, the form submits just as you'd expect. When I have that line in, however, it still calls the next page and executes that code, without the displayed page ever changing.
I have tested in both Chrome and Firefox, so I know it's not a browser issue, but this is really weird behavior. What am I doing wrong?
My goal: (1) validate the user's input, (2) give the user a clue that the page is going to take a while to load and (3) display the output from the action="complete.php" page once the PHP on it has run.
$.append()+? Much shorter thanjQuery.append().font-weight: bold;', you have a single quote but no terminating quote. Try \' instead.'mark matches to the<span style='marginone, no? I don't see any between them.