﻿ //Trim whitespace characters
 function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
 }

 //Checks the maxlength of text.  Used for multiline textboxes
 function isMaxLength(txtBox, maxLength)
 {
   if(txtBox)
   {
      //Truncate the value if it already exceeds the max length
      //NOTE: this happens when text is pasted in.
      if (txtBox.value.length > maxLength)
      {
         txtBox.value = txtBox.value.substr(0,maxLength);
      }
      return ( txtBox.value.length <= maxLength );
   }
 }   
 
  //Checks the maxlength of text and trims.  Used for multiline textboxes
 function trimLength(oldValue, maxLength)
 {
   if(oldValue)
   {
      var value = oldValue;
      if (oldValue.length > maxLength)
      {
         value = oldValue.substr(0, maxLength);
      }
      return value;
   }
 } 
