     //global variable for error flag
     var errfound = false;
     //function to validate by length
     function ValidLength(item, len)
         { return (item.length >= len); }
     // display an error alert
     function error(elem, text)
         { // abort if we already found an error
           if (errfound) return; window.alert(text);
           elem.select(); elem.focus(); errfound = true;
          }
     // student discount validation function
     function Validate2()
          { errfound = false;
            if (!ValidLength(document.schoolorder.os0.value,6))
               error(document.schoolorder.os0,"Invalid Name");
                  return !errfound; /* true if there are no errors */
          }
     // limiting order to stock on hand
     function Validate1(max)
          {
             document.regorder.quantity.value = Math.min(document.regorder.quantity.value,max);
             document.schoolorder.quantity.value = Math.min(document.schoolorder.quantity.value,max);
           }

