Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery disabling submit button
    primarykey
    data
    text
    <p>I have a form with a text box and a submit button. I disable the submit button once it is clicked for 5 seconds. If nothing is typed in the text field and the user tries submitting, the button is disabled for 1 second and nothing is posted. </p> <p>The problem I am having is that on a friends Mac in Chrome and Firefox, when the button is disabled, the button disappears and a grey box is left until the 5 seconds are up, but on my Windows computer with Chrome and Firefox the button is just faded out. Is there a reason why this is happening? He said that it was working fine and then it suddenly started happening.</p> <p>Here is my HTML:</p> <pre><code>&lt;form style="position:relative; top:-5px;" action="" method="post"&gt; &lt;strong&gt;Message:&lt;/strong&gt; &lt;input type="text" id="message" name="message" class="message"&gt; &lt;input type="submit" id="submit" value="Submit"/&gt; &lt;/form&gt; </code></pre> <p>And JavaScript:</p> <pre><code>&lt;script type="text/javascript"&gt; $(function() { refresh_shoutbox(); setInterval("refresh_shoutbox()", 15000); var running = false; $("#message").keypress(function(e) { if(e.which == 13 &amp;&amp; running === true) { return false; } }); $("#submit").click(function(event) { if(this.disabled) { event.preventDefault(); } if($("#message").val() != '') { running = true; $("#submit").attr("disabled","disabled"); setTimeout(function() { $("#submit").removeAttr("disabled") running = false; }, 5000); } else { $("#submit").attr("disabled", "disabled"); setTimeout(function() { $("#submit").removeAttr("disabled") running = false; }, 1000); return false; } // Ajax calls and the rest of the script </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload