...
 
 
 

WhigWham's FREE online resources! Our WhigCredit™ homepage ...

Click here to see this script do it's thing!Click here to see this script do it's thing!

Our WhigCredit™ add on for our "Do-It-All" WhigScript™ is an easy to configure javascript that integrates smoothly with the core WhigScript™ and WhigShop™ scripts. It is able to perform basic credit card "number vs. type" (based on the mod10 algorithm), and "expiry" date validations. This currently works with American Express, VISA and Mastercards only.

This script is FREE to download for personal or commercial use (see the foot of this page for the full copyright details).

As you might guess by now, like all of our javascripts, setting up WhigCredit™ is simplicity in itself. This is something we have tried to embrace with all of our javascripts. First, install our core WhigScript™ into your pages, then just follow these simple steps to use this script in your own web page(s):

WhigCredit™ Setup Instructions.
Step 1: You can include the WhigCredit™ into your own page directly, between the <HEAD> and <BODY> tags in your HTML page like this:


Alternatively, you can save the script as an external file by adding an external script link like this:


The latter option is recommended for 3 reasons. Firstly, this means that your user's browser only ever needs to download the albeit small script file once into its cache, and not each time your user visits another of your pages that utilises this script. Second, and most importantly for this script, you can then place this file in a hidden directory on your web server (a basic security technique). Lastly, IT IS EASIER!
Step 2: Setup your form (or forms) in a similar manner to that shown on our WhigScript™ Set Example Page. You can name the form whatever you like, but the name must be unique. You should name your form elements descriptively and uniquely, as they will be used in the in-built error reporting system shown to the web user. However, you must include the text strings "type", "number", "month" and "year" in the appropriate element's name as this is how the function distinguishes the elements apart (it also means you can have them in any order).
Step 3: Add an "onChange" event to every form element calling the "whigCredit" function. It should look something like this example of the "cardtype" element:


Note the use if the "*R" at the end of the element's name. This flags it for the WhigScript validator as a "required" element. In this way you can ensure that the user must enter a card number in a valid format to send the form - cool!

As an added feature, any default values in your forms' text or text-area elements can be cleared on entry (and restored on reset or exit) by adding this "onFocus" event calling one of the basic WhigScript™ functions:


Note that if you wish to use this feature, you MUST use the "onBlur" event handler for the whigCredit function call instead! See the instructions for our WhigScript™ for more on this, but it should look like:

Step 4: If you would like, you can now change the text shown to the user on alerts by editing the variables at the top of the script to what you require.
Step 5: Lastly, there is a single variable that you may need to adjust in the script itself. It is called "RememberCredit" and looks like this in the code:


As you may guess, this variable affects whether or not the user's credit card details are remembered by the WhigScript™ memory system. Some of the more security conscious amongst you may object to your user's credit card details being stored in a "cookie", and WhigWham understands that.

If you do choose to allow this option, please be aware that the values are only saved if ALL of the user's credit card details have been verified!
Step 6: All done!
Double-click to install this item directly, or right-click and select "Save As" to save to your hard-drive.
Version:
1.0
Updated:
02-Oct-01

Click here to see this script do it's thing!Click here to see this script do it's thing!

Now why not check out our additional "plug-ins" for our WhigScript™:

The WhigScript™ Set:
  WhigShop™ - the shopping cart.
  WhigMail™ - the email solution.
Our other scripts:
  WhigMCQ™ - a multi-choice exam tool.

The legal stuff:

 

 
Who is this guy? Find out more on our company information page...
Who is this guy? Find out more on our company information page...
 
Who is this guy? Find out more on our Company Information page...
Who is this guy? Find out more on our company information page...
Who is this guy? Find out more on our company information page...