{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20 /* This script and many more are available free online at\par
The JavaScript Source :: http://javascript.internet.com\par
Created by: Travis Beckham :: http://www.squidfingers.com | http://www.podlob.com */\par
\par
// |||||||||||||||||||||||||||||||||||||||||||||||||||||\par
//\par
// Coded by Travis Beckham\par
// http://www.squidfingers.com | http://www.podlob.com\par
// If want to use this code, feel free to do so, but\par
// please leave this message intact.\par
//\par
// |||||||||||||||||||||||||||||||||||||||||||||||||||||\par
// --- version date: 11/21/02 --------------------------\par
\par
// returns true if the string is empty\par
function isEmpty(str)\{\par
  return (str == null) || (str.length == 0);\par
\}\par
// returns true if the string is a valid email\par
function isEmail(str)\{\par
  if(isEmpty(str)) return false;\par
  var re = /^[^\\s()<>@,;:\\/]+@\\w[\\w\\.-]+\\.[a-z]\{2,\}$/i\par
  return re.test(str);\par
\}\par
// returns true if the string only contains characters A-Z or a-z\par
function isAlpha(str)\{\par
  var re = /[^a-zA-Z]/g\par
  if (re.test(str)) return false;\par
  return true;\par
\}\par
// returns true if the string only contains characters 0-9\par
function isNumeric(str)\{\par
  var re = /[\\D]/g\par
  if (re.test(str)) return false;\par
  return true;\par
\}\par
// returns true if the string only contains characters A-Z, a-z or 0-9\par
function isAlphaNumeric(str)\{\par
  var re = /[^a-zA-Z0-9]/g\par
  if (re.test(str)) return false;\par
  return true;\par
\}\par
// returns true if the string's length equals "len"\par
function isLength(str, len)\{\par
  return str.length == len;\par
\}\par
// returns true if the string's length is between "min" and "max"\par
function isLengthBetween(str, min, max)\{\par
  return (str.length >= min)&&(str.length <= max);\par
\}\par
// returns true if the string is a US phone number formatted as...\par
// (000)000-0000, (000) 000-0000, 000-000-0000, 000.000.0000, 000 000 0000, 0000000000\par
function isPhoneNumber(str)\{\par
  var re = /^\\(?[2-9]\\d\{2\}[\\)\\.-]?\\s?\\d\{3\}[\\s\\.-]?\\d\{4\}$/\par
  return re.test(str);\par
\}\par
// returns true if the string is a valid date formatted as...\par
// mm dd yyyy, mm/dd/yyyy, mm.dd.yyyy, mm-dd-yyyy\par
function isDate(str)\{\par
  var re = /^(\\d\{1,2\})[\\s\\.\\/-](\\d\{1,2\})[\\s\\.\\/-](\\d\{4\})$/\par
  if (!re.test(str)) return false;\par
  var result = str.match(re);\par
  var m = parseInt(result[1]);\par
  var d = parseInt(result[2]);\par
  var y = parseInt(result[3]);\par
  if(m < 1 || m > 12 || y < 1900 || y > 2100) return false;\par
  if(m == 2)\{\par
          var days = ((y % 4) == 0) ? 29 : 28;\par
  \}else if(m == 4 || m == 6 || m == 9 || m == 11)\{\par
          var days = 30;\par
  \}else\{\par
          var days = 31;\par
  \}\par
  return (d >= 1 && d <= days);\par
\}\par
// returns true if "str1" is the same as the "str2"\par
function isMatch(str1, str2)\{\par
  return str1 == str2;\par
\}\par
// returns true if the string contains only whitespace\par
// cannot check a password type input for whitespace\par
function isWhitespace(str)\{ // NOT USED IN FORM VALIDATION\par
  var re = /[\\S]/g\par
  if (re.test(str)) return false;\par
  return true;\par
\}\par
// removes any whitespace from the string and returns the result\par
// the value of "replacement" will be used to replace the whitespace (optional)\par
function stripWhitespace(str, replacement)\{// NOT USED IN FORM VALIDATION\par
  if (replacement == null) replacement = '';\par
  var result = str;\par
  var re = /\\s/g\par
  if(str.search(re) != -1)\{\par
    result = str.replace(re, replacement);\par
  \}\par
  return result;\par
\}\par
// validate the form\par
function validateForm(f, preCheck)\{\par
  var errors = '';\par
  if(preCheck != null) errors += preCheck;\par
  var i,e,t,n,v;\par
  for(i=0; i < f.elements.length; i++)\{\par
    e = f.elements[i];\par
    if(e.optional) continue;\par
    t = e.type;\par
    n = e.name;\par
    v = e.value;\par
    if(t == 'text' || t == 'password' || t == 'textarea')\{\par
      if(isEmpty(v))\{\par
        errors += n+' cannot be empty.\\n'; continue;\par
      \}\par
      if(v == e.defaultValue)\{\par
        errors += n+' cannot use the default value.\\n'; continue;\par
      \}\par
      if(e.isAlpha)\{\par
        if(!isAlpha(v))\{\par
          errors += n+' can only contain characters A-Z a-z.\\n'; continue;\par
        \}\par
      \}\par
      if(e.isNumeric)\{\par
        if(!isNumeric(v))\{\par
          errors += n+' can only contain characters 0-9.\\n'; continue;\par
        \}\par
      \}\par
      if(e.isAlphaNumeric)\{\par
        if(!isAlphaNumeric(v))\{\par
          errors += n+' can only contain characters A-Z a-z 0-9.\\n'; continue;\par
        \}\par
      \}\par
      if(e.isEmail)\{\par
        if(!isEmail(v))\{\par
          errors += v+' is not a valid email.\\n'; continue;\par
        \}\par
      \}\par
      if(e.isLength != null)\{\par
        var len = e.isLength;\par
        if(!isLength(v,len))\{\par
          errors += n+' must contain only '+len+' characters.\\n'; continue;\par
        \}\par
      \}\par
      if(e.isLengthBetween != null)\{\par
        var min = e.isLengthBetween[0];\par
        var max = e.isLengthBetween[1];\par
        if(!isLengthBetween(v,min,max))\{\par
          errors += n+' cannot contain less than '+min+' or more than '+max+' characters.\\n'; continue;\par
        \}\par
      \}\par
      if(e.isPhoneNumber)\{\par
        if(!isPhoneNumber(v))\{\par
          errors += v+' is not a valid US phone number.\\n'; continue;\par
        \}\par
      \}\par
      if(e.isDate)\{\par
        if(!isDate(v))\{\par
          errors += v+' is not a valid date.\\n'; continue;\par
        \}\par
      \}\par
      if(e.isMatch != null)\{\par
        if(!isMatch(v, e.isMatch))\{\par
          errors += n+' does not match.\\n'; continue;\par
        \}\par
      \}\par
    \}\par
    if(t.indexOf('select') != -1)\{\par
      if(isEmpty(e.options[e.selectedIndex].value))\{\par
        errors += n+' needs an option selected.\\n'; continue;\par
      \}\par
    \}\par
    if(t == 'file')\{\par
      if(isEmpty(v))\{\par
        errors += n+' needs a file to upload.\\n'; continue;\par
      \}\par
    \}\par
  \}\par
  if(errors != '') alert(errors);\par
  return errors == '';\par
\}\par
\par
/*\par
The following elements are not validated...\par
\par
button   type="button"\par
checkbox type="checkbox"\par
hidden   type="hidden"\par
radio    type="radio"\par
reset    type="reset"\par
submit   type="submit"\par
\par
All elements are assumed required and will only be validated for an\par
empty value or defaultValue unless specified by the following properties.\par
\par
isEmail = true;          // valid email address\par
isAlpha = true;          // A-Z a-z characters only\par
isNumeric = true;        // 0-9 characters only\par
isAlphaNumeric = true;   // A-Z a-z 0-9 characters only\par
isLength = number;       // must be exact length\par
isLengthBetween = array; // [lowNumber, highNumber] must be between lowNumber and highNumber\par
isPhoneNumber = true;    // valid US phone number. See "isPhoneNumber()" comments for the formatting rules\par
isDate = true;           // valid date. See "isDate()" comments for the formatting rules\par
isMatch = string;        // must match string\par
optional = true;         // element will not be validated\par
*/\par
\par
// ||||||||||||||||||||||||||||||||||||||||||||||||||\par
// --------------------------------------------------\par
// ||||||||||||||||||||||||||||||||||||||||||||||||||\par
\par
// All of the previous JavaScript is coded to process\par
// any form and should be kept in an external file if\par
// multiple forms are being processed.\par
\par
// This function configures the previous\par
// form validation code for this form.\par
function configureValidation(f)\{\par
  f.name.isAlphaNumeric = true;\par
  f.email.isEmail = true;\par
   var preCheck = (!f.infohtml.checked && !f.infocss.checked && !f.infojs.checked) ? 'select at least one checkbox.\\n' : null;\par
  return validateForm(f, preCheck);\par
\}\par
\par
}
 