How Can Forms Make Sure JavaScript Is Turned On?
Many forms use JavaScript to validate user input, prevent double-clicking, prevent auto-submission, and dynamically change field values. Among other things.
Without JavaScript, those forms don't work right.
This article contains methods of ensuring browsers have JavaScript turned on when a form is being used.
Omitting the Form
This method omits the entire form for non-JavaScript browsers. It's just not there.
Deliver the form with JavaScript. JavaScript browsers will see it. The others won't.
A NOSCRIPT tag can provide content in the form's stead for non-JavaScript browsers.
Redirecting To a Different Page
This method sends non-JavaScript browsers to a different web page.
JavaScript browsers will remain on the page. The others are redirected.
Put something like this into the HEAD area of the web page with the form:
<noscript> <meta http-equiv="refresh" content="0; URL=http://example.com/page.html"> </noscript>
Replace the URL in the meta tag with the URL of the web page where non-JavaScript browsers shall be redirected to.
Omitting the Submit Button
This method omits the submit button for non-JavaScript browsers. It's just not there.
Deliver the submit button with JavaScript. JavaScript browsers will see it. The others won't.
Here is an example:
document.write('<input type="submit" value="Send Form">');
Put the JavaScript between SCRIPT tags and use it instead of the HTML submit button code.
It may be kind to use a NOSCRIPT tag to let users of non-JavaScript browsers know to turn JavaScript on.
Choosing
The three methods are each quite different from the others.
The first omits the entire form. The second redirects to a different web page. And the third omits only the submit button.
Choose the one most useful in your situation.
In case you've wondered, a method that does not work so well is disabling the submit button.
With that method, the button is disabled when the page first loads. Then, JavaScript is used to enable the button.
The method can fail because some browsers will submit a form when the return/enter key is clicked, which bypasses the submit button.
Will Bontrager