{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20 /* For additional information about this JavaScript\par
and how to use it, see the "Displaying Number of Words\par
Typed Into Form Fields" article, linked from the archives\par
at from http://willmaster.com/possibilities/archives/\par
The above note and the copyright line must remain with\par
this JavaScript source code. Comments below this point\par
in the code may be removed if desired. */\par
\par
// Customizing this JavaScript code requires specifying eight values.\par
\par
// Value One:\par
// Specify the maximum number of characters the form field\par
// may contain. If you have no maximum, specify 0 (zero).\par
\par
var MaximumCharacters = "300";\par
\par
// Value Two:\par
// Specify the maximum number of words the form field may\par
// contain. If you have no maximum, specify 0 (zero).\par
\par
var MaximumWords = "50";\par
\par
// Value Three:\par
// Specify the form's name (provided by the name="_____"\par
// attribute in the FORM tag).\par
\par
var FormName = "calendarsubmit";\par
\par
// Value Four:\par
// Specify the name of the text field being monitored\par
// (provided by the name="_____" attribute in the\par
// INPUT or TEXTARE tag).\par
\par
var TextFieldName = "description";\par
\par
// Value Five:\par
// Specify the field name where where is to be displayed\par
// the number of characters the user has typed. Make\par
// it blank (nothing between the quotation marks) if\par
// you aren't displaying the number of characters typed.\par
\par
var CharactersTypedFieldName = "";\par
\par
// Value Six:\par
// Specify the field name where where is to be displayed\par
// the number of characters left that may be typed.\par
// Make it blank (nothing between the quotation marks)\par
// if you aren't displaying the number of characters\par
// left.\par
\par
var CharactersLeftFieldName = "";\par
\par
// Value Seven:\par
// Specify the field name where where is to be displayed\par
// the number of words the user has typed. Make it\par
// blank (nothing between the quotation marks) if you\par
// aren't displaying the number of words typed.\par
\par
var WordsTypedFieldName = "";\par
\par
// Value Eight:\par
// Specify the field name where where is to be displayed\par
// the number of words left that may be typed. Make it\par
// blank (nothing between the quotation marks) if you\par
// aren't displaying the number of words left.\par
\par
var WordsLeftFieldName = "WordsLeft";\par
\par
//////////////////////////////////////////////////////\par
//                                                  //\par
//  No modfications are required below this point.  //\par
//                                                  //\par
//////////////////////////////////////////////////////\par
\par
var WordsMonitor = 0;\par
var MaxWords = parseInt(MaximumWords);\par
var MaxChars = parseInt(MaximumCharacters);\par
var textfield = 'document.' + FormName + '.' + TextFieldName + '.value';\par
\par
function WordLengthCheck(s,l) \{\par
WordsMonitor = 0;\par
var f = false;\par
var ts = new String();\par
for(var vi = 0; vi < s.length; vi++) \{\par
\tab vs = s.substr(vi,1);\par
\tab if((vs >= 'A' && vs <= 'Z') || (vs >= 'a' && vs <= 'z') || (vs >= '0' && vs <= '9')) \{\par
\tab\tab if(f == false)\tab\{\par
\tab\tab\tab f = true;\par
\tab\tab\tab WordsMonitor++;\par
\tab\tab\tab if((l > 0) && (WordsMonitor > l)) \{\par
\tab\tab\tab\tab s = s.substring(0,ts.length);\par
\tab\tab\tab\tab vi = s.length;\par
\tab\tab\tab\tab WordsMonitor--;\par
\tab\tab\tab\tab\}\par
\tab\tab\tab\}\par
\tab\tab\}\par
\tab else \{ f = false; \}\par
\tab ts += vs;\par
\tab\}\par
return s;\par
\} // function WordLengthCheck()\par
\par
function CharLengthCheck(s,l) \{\par
if(s.length > l) \{ s = s.substring(0,l); \}\par
return s;\par
\} // function CharLengthCheck()\par
\par
function InputCharacterLengthCheck() \{\par
if(MaxChars <= 0) \{ return; \}\par
var currentstring = new String();\par
eval('currentstring = ' + textfield);\par
var currentlength = currentstring.length;\par
eval('currentstring = CharLengthCheck(' + textfield + ',' + MaxChars + ')');\par
if(CharactersLeftFieldName.length > 0) \{\par
\tab var left = 0;\par
\tab eval('left = ' + MaxChars + ' - ' + textfield + '.length');\par
\tab if(left < 0) \{ left = 0; \}\par
\tab eval('document.' + FormName + '.' + CharactersLeftFieldName + '.value = ' + left);\par
\tab if(currentstring.length < currentlength) \{ eval(textfield + ' = currentstring.substring(0)'); \}\par
\tab\}\par
if(CharactersTypedFieldName.length > 0) \{\par
\tab eval('document.' + FormName + '.' + CharactersTypedFieldName + '.value = ' + textfield + '.length');\par
\tab if(currentstring.length < currentlength) \{ eval(textfield + ' = currentstring.substring(0)'); \}\par
\tab\}\par
\} // function InputCharacterLengthCheck()\par
\par
function InputWordLengthCheck() \{\par
if(MaxWords <= 0) \{ return; \}\par
var currentstring = new String();\par
eval('currentstring = ' + textfield);\par
var currentlength = currentstring.length;\par
eval('currentstring = WordLengthCheck(' + textfield + ',' + MaxWords + ')');\par
if (WordsLeftFieldName.length > 0) \{\par
\tab var left = MaxWords - WordsMonitor;\par
\tab if(left < 0) \{ left = 0; \}\par
\tab eval('document.' + FormName + '.' + WordsLeftFieldName + '.value = ' + left);\par
\tab if(currentstring.length < currentlength) \{ eval(textfield + ' = currentstring.substring(0)'); \}\par
\tab\}\par
if (WordsTypedFieldName.length > 0) \{\par
\tab eval('document.' + FormName + '.' + WordsTypedFieldName + '.value = ' + WordsMonitor);\par
\tab if(currentstring.length < currentlength) \{ eval(textfield + ' = currentstring.substring(0)'); \}\par
\tab\}\par
\} // function InputWordLengthCheck()\par
\par
function InputLengthCheck() \{\par
InputCharacterLengthCheck();\par
InputWordLengthCheck();\par
\} // function InputLengthCheck()\par
\par
}
