// JavaScript Document

function checkform()
{
	var Field= Array();
	var FieldName= Array();
	
	Field[0]=document.frmCheck.txtFname;
	Field[1]=document.frmCheck.txtLname;
	Field[2]=document.frmCheck.txtEmail;
	Field[3]=document.frmCheck.txtPhone;
	Field[4]=document.frmCheck.txtComments;

	FieldName[0]="First Name ";
	FieldName[1]="Last Name ";
	FieldName[2]="Email Address ";
	FieldName[3]="Phone Number ";
	FieldName[4]="Comments ";
	
	
	var msg="";
	var bval = true;
	
	for(i=0; i<5; i++)
	{
		if(Field[i].value=="" || Field[i].value==null)
		{
			//alert("Please fill " + FieldName[i] + " field.");
			msg = msg + "Please Fill:"
			msg = msg + "\n" + ">> " + FieldName[i];
			alert(msg);
			Field[i].focus();
			bval = false;
			break;
		}
		
	}
	
	
	if(bval)
	{
		bval=emailCheck();
	}
	/*
	if(bval)
	{
		if(isNaN(Field[3]))
		{
			bval = false;
			alert("Invalite Phone Number");
		}
	}*/
	
	if(bval)
	 {
		bval= PhoneCheck(document.frmCheck.txtPhone.value);
	 }
	 
	return bval;
}

function PhoneCheck(strPhone) 
  	{  	  		  	  		
			strPhone=strPhone.replace(/[^0-9]/g, ''); 
		
			if(strPhone.length>10){
				alert("Invalid Phone Number");
				return false;
			}
			return true;	  	  	
    }
	
function emailCheck() 
  	{
  	  		var emailPat=/^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/
  	        var matchArray;	
  	  		var emailStr1 =document.frmCheck.txtEmail.value;	
  	  		
					matchArray = emailStr1.match(emailPat);
					if (matchArray == null) 
					
					{
						alert("Please Enter Valid Email Address"); 
						document.frmCheck.txtEmail.focus();
						return false;
					}	
					else 
					return true;
	  	
    }


	
