This is a set of validation functions that I have used over the years, making mods as needed. It works good for me so maybe someone else will find it useful too. Its all for IE (should work with 4, 5 and 6)

One of the main aims was to cut down on alerts() and give the user a graphical alert that something was wrong.

-----------Begin ValFunctions.js----------------
Code:
//** START focus/hilite/reset element **
function fHighlightTextBox(tbObject) {	
   tbObject.select();
}
function fFocusTextBox(tbObject) {
   tbObject.focus();
}
function fSetTextBoxActive(tbObject) {
   fFocusTextBox(tbObject);
   fHighlightTextBox(tbObject);
}
function fRedoTextBoxInput(tbObject, SetToVal) {
   tbObject.value=SetToVal;
   fSetTextBoxActive(tbObject);
}
//** END focus/hilite/reset element **


//** START  Color change based alerts **
function fSetBkColor(element, bg) {
   // backgound color change function...WRG
   if (element.style) element.style.backgroundColor = bg;
}
function fSetGoodBKColor() {
   return "#ffffff"; //return "transparent";
}
function fSetBadBKColor() {
   return "#cccc99"; 
}
function fSilentAlert(element, pick) {
   var bgBad = fSetBadBKColor();
   var bgGood = fSetGoodBKColor();
   if (pick == "bad") {
      fSetBkColor(element, bgBad);	
   } else {
      fSetBkColor(element, bgGood);	
   }
}
function fIsBKColorBad(element) {
   var test = false;
   if (element.style) {
      test = (element.style.backgroundColor == fSetBadBKColor());
   }
   return test;
}
//** END  Color change based alerts **


//** START  Date validation functions **
function fIsLeapYear(intY){
   if(((intY % 4)==0) && ((intY % 100)!=0) || ((intY % 400) == 0)) {
      return true;
   } else {
      return false;
   }
}
function fDaysInMonth(intM, intY) {
   if (intM == 2) {
      if (fIsLeapYear(intY)) {
         return 29;
      } else {
         return 28;
      }
   } else {
      if ((intM == 4)||(intM == 6)||(intM == 9)||(intM == 11)) {
         return 30;
      } else {
         if (intM <= 12) {
            return 31;
         } else {
            return 0;
         }
      }
   }
}
// Date format function...WRG
function fIsDate(strDate, strOrder, strDelimter) {
   // strOrder contains one or more of these letters (m,d,y) will add (h,n,s) to the list later...WRG
   var boolResults = false;
   var strM, strD, strY;//, strH, strN, strS;
   for (i=0;i<strOrder.length;i++){
      boolResults = false;
      if (strDate.indexOf(strDelimter,0) >= 0) {
         strCurrentPart = strDate.substr(0,strDate.indexOf(strDelimter,0));
         strDate = strDate.substr(strDate.indexOf(strDelimter,0)+1,strDate.length);
      } else {
         strCurrentPart = strDate;
         strDate = "";
      }
      if (!isNaN(strCurrentPart)) {
         switch (strOrder.substr(i,1)){
            case 'm':
               if ((strCurrentPart>0) && (strCurrentPart<13)) {
                  strM = strCurrentPart;
                  boolResults = true;
               }
               break;
            case 'd':
               if ((strCurrentPart>0) && (strCurrentPart<32)) {
                  strD = strCurrentPart;
                  boolResults = true;
               }
               break;
            case 'y':
               if (((strCurrentPart>0) && (strCurrentPart<100) && (strCurrentPart.length=2)) || ((strCurrentPart>999) && (strCurrentPart<10000) && (strCurrentPart.length=4))) {
                  strY = strCurrentPart;
                  boolResults = true;
               }
               break;
            default:
               boolResults = false;
               break;
         } // END switch (strOrder.substr(i,1))
      } // END if (!isNaN(strCurrentPart))
      if (!(boolResults)) {
         break;
      }
   } // END for (i=0;i<strOrder.length;i++)
   if (boolResults) {
      boolResults = (strD<=fDaysInMonth(strM,strY));
   }
   return boolResults;
}
//** END  Date validation functions **


//** START Other validation functions **
function fIsBlank(s) {
   // Check to see if string is blank, yes there is a better way...WRG
   var len=s.length
   var i
   for(i=0;i<len;++i) {
      if (s.charAt(i)!=" ") return false
   }
   return true
}
function fIsValInteger(tbObject, boolBlankOK, boolGoBack) {
   // Check for valid integer...WRG
   fSilentAlert(tbObject, "good");
   if (fIsBlank(tbObject.value)) {
      if (!(boolBlankOK)) {
         fSilentAlert(tbObject, "bad");	
         if (boolGoBack){
            fSetTextBoxActive(tbObject);
         }
      }
   } else {
      if (isNaN(tbObject.value)) {
         fSilentAlert(tbObject, "bad");	
         if (boolGoBack)	{
            fSetTextBoxActive(tbObject);
         }
      }
   }
}
function fIsValDate(tbObject, strOrder, strDelimter, boolBlankOK, boolGoBack) {
   // Check for valid date...WRG
   fSilentAlert(tbObject, "good");
   if (fIsBlank(tbObject.value)) {
      if (!(boolBlankOK)) {
         fSilentAlert(tbObject, "bad");	
         if (boolGoBack)	{
            fSetTextBoxActive(tbObject);
         }
      }
   } else {
      if (!(fIsDate(tbObject.value, strOrder, strDelimter))) {
         fSilentAlert(tbObject, "bad");	
         if (boolGoBack)	{
            fSetTextBoxActive(tbObject);
         }
      }
   }
}
function fIsValString(tbObject, boolBlankOK, boolGoBack) {
   // Check for valid string...WRG
   fSilentAlert(tbObject, "good");	
   if (fIsBlank(tbObject.value)){
      if (!(boolBlankOK)) {
         fSilentAlert(tbObject, "bad");
         if (boolGoBack)	{
            fSetTextBoxActive(tbObject);
         }
      }
   }
}
function fDateInRange(tbObject, strOrder, strDelimter, strStartRange, strEndRange){
   fIsValDate(tbObject, strOrder, strDelimter, false, false);
   if (!(fIsBKColorBad(tbObject))) {
      if ((Date.parse(tbObject.value) < Date.parse(strStartRange)) ||
         (Date.parse(tbObject.value) > Date.parse(strEndRange))) {
         fSilentAlert(tbObject, "bad");
      }
   }
}
function fValidateNonNegNumber(tbObject){
   fIsValInteger(tbObject, false, false);
   if (!(fIsBKColorBad(tbObject))){
      if (tbObject.value < 0){
         fSilentAlert(tbObject, "bad");
      }
   }
}
function fPadOrRoundReal(tbPadIt, percision){
   if (!(fIsBKColorBad(tbPadIt))){
      var strRealAsIntWithFullPercision = new String(Math.ceil((tbPadIt.value * Math.pow(10, percision)) - 0.5));
      if (strRealAsIntWithFullPercision != "0") {
         tbPadIt.value = strRealAsIntWithFullPercision.substring(0, strRealAsIntWithFullPercision.length - percision) + "." + strRealAsIntWithFullPercision.substring(strRealAsIntWithFullPercision.length - percision);
      } else {
         tbPadIt.value = "0." + String(Math.pow(10, percision)).substring(1, percision + 1);
      }
   }
}
//** END Other validation functions **
-------------End ValFunctions.js-----------------