Disable submit button with JavaScript

Imagine you create a beautiful form with lots of controls to validate made in Ajax, in this case it is essential that the user’s browser has JavaScript enabled form,step for this:

  1. Detect activation or not support JavaScript;
  2. Require the navigator to enable support missing;
  3. Block the form’s submit button until JavaScript is enabled.

To do this enough very few lines of code, first fix this Alert in a prominent place on the page (if possible before the beginning of the form or just before the submit button):

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left;"><noscript></span> <noscript></span>

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left;"><h1>Attenzione!</span> <h1> Warning!</span> <span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left;">Per poter proseguire devi abilitare JavaScript.</h1></span> In order to continue you need to enable JavaScript. </ H1></span>

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left;"></noscript></span> </ Noscript></span>

Now the next and final step will be on the disabling submit button:

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left;"><script type="text/javascript"></span> <script type="text/javascript"></span>

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left;">document.write('<input type="submit" value="Procedi con l\'iscrizione" />');</span> document.write ('<input type="submit" value="Procedi with l\'iscrizione" />');</span>

<span onmouseover="_tipon(this)" onmouseout="_tipoff()"><span class="google-src-text" style="direction: ltr; text-align: left;"></script></span> </ Script></span>

All done. The submit button will be visible only if JavaScript is enabled.

This entry was posted in Scripting and tagged , . Bookmark the permalink.

Comments are closed.