Software, your way.
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!

Guarantee JavaScript for Forms

Tech-oriented websites like Willmaster.com attract technically oriented folks. Some, perhaps many, arrive with their browser's JavaScript turned off.

Which is fine. Except when it's not.

An example of when it's not fine is when a form requires JavaScript to perform correctly.

There are many reasons forms may require JavaScript. Examples are to insert/dynamically change values of fields, prevent double-clicking on buttons, or to provide appropriate assistance.

The most imperative reason to require JavaScript, at least for Willmaster.com, is to block unwanted form submissions and reduce form spam. Without JavaScript, a form will either not submit or fail silently.

When a form is there and the person finds they can't use it or it won't submit, it can be frustrating.

To eliminate the frustration, or most of it, a noscript tag can be inserted near the top of the form, or near the submit button, with the message that JavaScript is required to use the form. Here is an example.

<noscript>
<h4>Note: JavaScript is required to make this form fully functional.</h4>
</noscript>

But that doesn't guarantee JavaScript will be available for the form. Further, the message might not be seen or the form just abandoned.

A way to guarantee JavaScript will be available when someone uses your form is to deliver it with JavaScript. Without JavaScript, the form never becomes available to be used.

There are various ways to deliver forms to a web page with JavaScript. Any of them will ensure the browser can run JavaScript before the form is made available.

Here are three ways:

  1. Insert the form with a regular JavaScript tag.

  2. Publish the form with Ajax.

  3. Use a Spam-free form.

Here are descriptions of the three methods:

Insert the form with a regular JavaScript tag.

With this method, you convert your form to JavaScript, store the JavaScript in a file on your server, and insert the form into your web page with a JavaScript tag.

  1. Use the Text to JavaScript Converter to convert your form source code into JavaScript.

  2. Save the JavaScript as myform.js or other .*js file name that you prefer. Upload it to your server and make a note of its URL.

  3. In the source code of the web page where the form is to be delivered, insert:

    <script src="http://example.com/myform.js>" type="text/javascript"></script>
    

    Replace https://example.com/myform.js with the URL to the JavaScript you uploaded to your server in the previous step.

The form will be delivered to your web page only for browsers that run JavaScript.

Publish the form with Ajax.

This method does not slow the web page load in order to insert the form. With Ajax, the form is published when the browser gets around to it.

There are a number of ways to do this, but all are basically the same: The Ajax obtains the form source code from the server. Then it publishes the source code into a specific div.

The Ajax Form System article contains a how-to for one method. Using the system will display your form on your web page with Ajax.

Use a Spam-free form.

A spam-free form as obtained from SpamFreeForm.com not only ensures the browser has JavaScript enabled, it is highly effective at blocking spam.

While I can never guarantee this, because spammers get ever more creative, I believe spam-free form completely blocks all automated spam.

The service has been in operation for some years. There has been no confirmed instance of a form-spamming bot successfully using the form. And the form still remains easy to use — without requiring people to proactively prove they are human.

The service is free.

A Good Reason

A good reason for providing forms only to browsers with JavaScript enabled, in addition to ensuring the browser's JavaScript is actually turned on, is form spam prevention.

As mentioned, the spam-free form is highly effective at blocking automated form spamming. The other two methods also are fairly good at that because most form spamming bots (so far) don't compile and run JavaScript.

(This article first appeared with an issue of the Possibilities newsletter.)

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