Software, your way.
How To Get Good Custom Software
(Download)
(PDF)
burger menu icon
WillMaster

WillMaster > LibraryManaging Website Forms

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

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

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC