//--------------------------------------------------------------------
//	val_qty_min_10.js
//--------------------------------------------------------------------

function ValidateQty(field)
{
    //alert(field); 
    //alert(field.value); 
	// strip leading and trailing blanks from string
	stripSpaces(field);
	//check if something was entered
   if(isEmpty(field.value)) 
   { 
      alert('You have not entered a quantity'); 
      field.focus(); 
      return false; 
   } 
 
	// check if only numbers 0->9 were entered 
   if (!IsNumeric(field.value)) 
   { 
      alert('Please enter a whole number with no decimals in the quantity field'); 
      field.focus(); 
      return false; 
	}
	
	// check if less than 10 was entered
	var num = parseInt(field.value);
	if(num < 10)
	{
      alert('Minimum order quantity is 10'); 
	  field.focus(); 
      return false; 
	}
 
	return true;
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (var i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}

function isEmpty(field)
{
	return ((field == null) || (field.length == 0)) 
}

function stripSpaces(field)
{
	var x = field.value;
	while (x.substring(0,1) == ' ') x = x.substring(1);
	while (x.substring(x.length-1,x.length) == ' ') x = x.substring(0,x.length-1);
	field.value = x;
}

