////////////////////////////////////////////////////////////////////////////////
// SCRIPT NAME: MD Form Validation 1.0                                        //
//     UPDATED: October 10, 2003                                              //
//   COPYRIGHT: ©2003 Matthew J. Drollinger                                   //
//              Strong Interactive Media, Inc. - www.strongim.com             //
// DESCRIPTION: This script will validate data in any type of form element    //
//              whose name is called in the checkForm function.  It can be    //
//              used to determine if an element has a value, or to determine  //
//              if an element's value is formatted correctly.                 //
//              This script works on Netscape 4+ and IE 4+ browsers.          //
//       USAGE: For commercial use of this script contact:                    //
//              Strong Interactive Media - (262)236-4228 - www.strongim.com   //
////////////////////////////////////////////////////////////////////////////////

function hasValue(theField){var fieldType; if(theField[0] && theField[0].type)fieldType = theField[0].type; else fieldType = theField.type; if(fieldType=="text" || fieldType=="password" || fieldType=="textarea" || fieldType=="file" || fieldType=="hidden"){if(theField.value.length==0) return false; else return true;} else if(fieldType.indexOf("select") > -1){var hasAVal = 0; for(i=0;i<theField.options.length;i++){if(theField.options[i].selected && theField.options[i].value != "") hasAVal = 1;} if (hasAVal) return true; else return false;} else if(fieldType=="radio"){var r_ok=0; for(i=0;i<theField.length;i++){if(theField[i].checked) r_ok=1;} if(!r_ok) return false; else return true;} else if(fieldType=="checkbox"){if(theField.checked) return true; else return false;}}
function isNumeric(theValue){if(isNaN(theValue) || theValue == "") return false; else return true;}
function isInteger(theValue){if(isNumeric(theValue) && theValue.indexOf('.') < 0) return true; else return false;}
function isFullName(theValue){if(/[a-z\.]+\s+[a-z\.]+/i.test(theValue)) return true; else return false;}
function isEmail(theValue){if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/i.test(theValue)) return true; else return false;}
function isAbsoluteURL(theValue){if(/^.+:\/\/.+\..+$/i.test(theValue)) return true; else return false;}
function isMonth(theValue){if(isInteger(theValue) && theValue>0 && theValue<=12) return true; else return false;}
function isDay(theValue){if(isInteger(theValue) && theValue>0 && theValue<=31) return true; else return false;}
function isYear(theValue){if(isInteger(theValue) && theValue.length==4 && theValue.charAt(0) != '0') return true; else return false;}
function isDate(theMonth,theDay,theYear){var validDateParts=0, isValidDate=0; if(isMonth(theMonth) && isDay(theDay) && isYear(theYear)) validDateParts = 1; enteredDate = new Date(); enteredDate.setMonth(theMonth-1); enteredDate.setDate(theDay); enteredDate.setYear(theYear); if(enteredDate.getDate() == theDay) isValidDate = 1; if(validDateParts && isValidDate) return true; else return false;}
function isAlphaNumPW(theValue){if(/^[a-z_][a-z0-9_]*$/i.test(theValue)) return true; else return false;}
function isSSNum(theValue){if(/^\d{3}[- ]*\d{2}[- ]*\d{4}$/.test(theValue)) return true; else return false;}
function isCCNum(theValue){if(/^((4\d{3})|(5[1-5]\d{2})|(6011))[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}|3[4,7]\d{13}$/.test(theValue)) return true; else return false;}
function isLocalPhoneNum(theValue){var numCount=0;for(j=0; j<theValue.length; j++){if(isInteger(theValue.charAt(j))) numCount++;} if(/^[0-9\-\s\(\)\*#ext\.]+$/i.test(theValue) && numCount>=7) return true; else return false;}
function isPhoneNum(theValue){var numCount=0;for(j=0; j<theValue.length; j++){if(isInteger(theValue.charAt(j))) numCount++;} if(/^[0-9\-\s\(\)\*#ext\.]+$/i.test(theValue) && numCount>=10) return true; else return false;}
function isZip(theValue){if(/^\d{5}(-\d{4})?$/.test(theValue)) return true; else return false;}
function hasFileExtension(theValue,theExtensionList){var reg = new RegExp("\\.(" + theExtensionList.replace(/( |\.)/gi,"").replace(/,/gi,"|") + ")$","gi"); if(reg.test(theValue)) return true; else return false;}
function isHexColor(theValue){if(/^[A-F0-9]{6}$/i.test(theValue)) return true; else return false;}
