The Count Field Input Action will keep track of how many words or characters have been entered into a form field. The resulting character or word count can then be displayed in another form text field, stored in a hidden field, written into a GoLive layer or <div> tag, or stored as a variable to be used by the Form Calculator Action.
If you haven’t already, you’ll first need to download a copy of the action file.
- DOWNLOAD FILE (.zip archive)
Decompress the ZIP file and put it into a new folder named “MindPalette” (if you don’t already have a MindPalette folder in your GoLive actions). Put the MindPalette folder into your GoLive actions folder, which you can find here on your computer:
(Main GoLive Folder) / Modules / JScripts / Actions
After installing the action, be sure to restart GoLive so the action will be available for use.
To use the action, select the form text area you wish to track and open the Actions Palette (Rollovers and Actions in GoLive CS 1). In the list of events at the top left of the palette, choose the one to trigger the action to update your count (I generally recommend using the Key Up event). Click the “New Action” icon at the bottom of the right column in the Actions Palette (the icon looks like a page with a turned-up corner). Then, choose the Count Field Input action from the Action menu below (should be in your MindPalette sub-group).
Next, you’ll just need to use the fields in the actions palette to customize how things should work. Those options are described below:
- form name
- Enter the name of your HTML form. The field being counted and any fields used to store the total will need to be inside the same form.
- count in field
- Enter the name of the field whose text you’re input you’re trying to count/track.
- count type
counts the number of words – any character group separated by a space.
- characters (whitespace):
counts every character, including spaces and returns
- characters (no whitespace):
counts every character except white space (spaces, tabs and returns)
- maximum input count
- Set to the maximum count allowed (using methods above). Leave this setting blank or set to 0 to not use a limit.
- maximum alert message
- If you’d like an alert message to pop up when a visitor tries to enter more characters or words than are allowed by the maximum setting, enter your alert message here.
COPY RESULTS TO:
The following options determine what the action does with the results of its count. You can use more than one method if you wish (variable + form field + display div, for instance).
- form field
- Enter the name of a form text field or hidden field that you’d like to use to store the count status (optional).
- div or layer id
- Enter the ID of your <div> or Layer that will have the results written into it (any other content in that layer or div will be replaced by the current count text).
- form calc variable
- Enter the name of your variable that can later be used by the Form Calculator Action. (optional)
- display type menus
- Under the three display/storage options is a menu to either use the current count, or use the countdown from the maximum count. For instance, if 10 words are allowed, and the visitor has entered 2 words, it would use “2” with the normal count setting, and “8” with the countdown setting.
WORD COUNT OPTIONS:
The last couple of options were added to give greater control over what is considered a “word” when using the word count type (does not apply to the character count type).
- separator characters
- Enter any characters to count as word separators. In the above example, I’ve added . and / to account for long URLs as mutliple words. There’s no need to enter white space characters (spaces, tabs, returns, etc.) since they are already considered to be word separators by default.
- consecutive as single
- Checking this options will tell the script to treat consecutive word separator characters as one separator, so both “word1 word2” and “word1. / word2” would count as 2 words in the example shown.
Your action should now be ready for testing. When adding a new action to your site, particularly in GoLive CS2, you should always flatten and re-upload your site’s GeneratedItems/CSScriptLib.js file to be sure GoLive refreshes its script library to include the code needed for the action. To flatten the script library, right click (or control+click on Mac) the CSScriptLib.js file (inside the GeneratedItems folder at the top level of your site) and choose Flatten Script Library (or Update > Flatten Script Library in GoLive CS2).
If you have any trouble, please consult the Actions FAQ here:
…or post a question in our online support forum: