function alltrim(str) 
{
                return str.replace(/^\s+|\s+$/g, '');
 }
 
 function IsNumeric(strString)
   	//  check for valid numeric strings	
   	{
  		var strValidChars = "0123456789- ";
   		var strChar;
  		var blnResult = true;
   		if (strString.length == 0) return false;
		//  test strString consists of valid characters listed above
   		for (i = 0; i < strString.length && blnResult == true; i++)
      	{
      		strChar = strString.charAt(i);
      		if (strValidChars.indexOf(strChar) == -1)
         	{
         		blnResult = false;

         	}
      	}
   		return blnResult;
   	} 


function validForm()
{
	//alert("check");	
	//alert(document.frm.small.value);	 
 	if(alltrim(document.frm.name.value) == "" )
	{
		alert("Please enter your name.");
		document.frm.name.focus();
		return false;
	}
	
	if(alltrim(document.frm.phone.value) == "" )
	{
		alert("Please enter your phone number in full, including area code and no spaces.");
		document.frm.phone.focus();
		return false;
	}
	
if (!IsNumeric(document.frm.phone.value))
{

alert ("Please enter your phone number in full, including area code and no spaces.");
document.frm.phone.focus();
return false;
}
//alert(document.frm.phone.value.length);	 
if ((document.frm.phone.value.length < 8)) {
alert ("Phone no. should be minimum 8 characters.");
document.frm.phone.focus();
return false;
}
	
		
	if(alltrim(document.frm.email.value) == "" )
	{
		alert("Please enter email address.");
		document.frm.email.focus();
		return false;
	}
	else
	{
		emailExp= /^\w+(\-\w+)*(\.\w+(\-\w+)*)*@\w+(\-\w+)*(\.\w+(\-\w+)*)+$/;
	 	 if (!(emailExp.test(document.frm.email.value)))
		{ 
			   alert("Invalid email address.");
			   document.frm.email.focus();
			   return false;  
		} 
	}
if(alltrim(document.frm.comments.value) == "" )
	{
		alert("Please enter comments.");
		document.frm.comments.focus();
		return false;
	}
	
		
}

