///***********************************************************************/
// functions for handling validation of forms involving numbers and passwords

///***********************************************************************/
// functions defined are:
//    cleanString (theField)
//    checkNumeric (theField, str, showPopUp)

///***********************************************************************/
//Trim leading and trailing blanks from input strings.
function cleanString(theField)
{
var count1 = 0;
var count2 = 0;
var testString1 = new String();
var testString2 = new String();
testString1 = theField.value;
var long1 = theField.value.length;
var long2;
//Count the number of leading blanks.
	i=0;
	while (theField.value.charAt(i) == " ")
		{
		count1++;
		i++;
		}
//Make a substring from testString1 which excludes the leading blanks. 	
	testString1 = theField.value.substring(count1, long1);

//Replace the string as input with the same string without the leading blanks.

theField.value = testString1;

//Determine the number of trailing blanks.

long2 = theField.value.length;
var i = long2-1;
while (theField.value.charAt(i) == " ")
	{
	count2++;
	i--;
	}
//Make another substring testString2 which excludes the trailing blanks.

testString2 = theField.value.substring(0, (long2 - count2));

//Replace the value of the string with the same string without any leading or trailing blanks.

theField.value = testString2; 
}

///***********************************************************************   
//Check if the string is numeric 
function checkNumeric(theField, str, showPopUp)					
{
var testString = theField.value;

if (testString.length < 1)
   {
       if (showPopUp) 
          {
            alert("Invalid entry.  The " + str + " field must be non-empty and contain only numeric characters.");
            theField.focus();
          }
       return false;
   }

for (i=0; i < testString.length;  i++)
    {
        if ((testString.charAt(i) >= "0") && (testString.charAt(i)<= "9"))
            {
                
            }
        else
            {
                if (showPopUp) 
                   {
                      alert("Invalid entry.  The " + str + " field must contain only numeric characters.");
                      theField.focus();
                   }
                theField.value = "";
                return false;
            }
    }
    return true;
}

///***********************************************************************/

