// JavaScript Document
function formvalidation()
{
    var Field= Array();
	var FieldName= Array();

	/*Applicant Filed*/
	
	Field[0]=document.formreg.txtFstnam.value;
	Field[1]=document.formreg.txtLstnam.value;
	Field[2]=document.formreg.txtUsrnam.value;
	Field[3]=document.formreg.txtPwd.value;
	Field[4]=document.formreg.txtCpwd.value;
	Field[5]=document.formreg.txtAdd.value;
	Field[6]=document.formreg.txtCity.value;
	Field[7]=document.formreg.txtStat.value;
	Field[8]=document.formreg.txtZip.value;
	Field[9]=document.formreg.txtEmail.value;
	Field[10]=document.formreg.txtGender.value;
	Field[11]=document.formreg.txtDbo.value;
	
	FieldName[0]="First Name ";
	FieldName[1]="Last Name ";
	FieldName[2]="User Name ";
	FieldName[3]="Password ";
	FieldName[4]="Confirm Password ";
	FieldName[5]="Address ";
	FieldName[6]="City ";
	FieldName[7]="State ";
	FieldName[8]="Zip ";
	FieldName[9]="Email ";
	FieldName[10]="Gender ";
	FieldName[11]="DBO ";

	/*Applicant Filed End*/
	

	var msg="Please Fill:";
	var bval=true;
	
	for(i=0; i<=11; i++)
	{
		if(Field[i] == "")
		{
			msg = msg + "\n" + ">> " + FieldName[i];
			bval = false;
		}
	}
			
	if(msg != "Please Fill:")
	{
		alert(msg);
	}
	if(bval)
	{
		bval = emailCheck();
		document.formreg.txtEmail.focus();
	}
	if(bval)
	{
		bval = password();
	}
	return bval;
}
function emailCheck() 
  	{
  	  		var emailPat=/^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/
  	        var matchArray;	
  	  		var emailStr1 =document.formreg.txtEmail.value;	
			
  	  	
  	  		
					matchArray = emailStr1.match(emailPat);
					if (matchArray == null) 
					
					{
						alert("Please Enter Correct Email Address");
						document.formreg.txtEmail.value="";
						document.formreg.txtEmail.focus;
						return false;
					}	
					else 
					return true;
	  	
    }

function password() 
  	{
  	  		var pwd=document.formreg.txtPwd.value;
  	        var cpwd=document.formreg.txtCpwd.value;
			var uid=document.formreg.txtUsrnam.value;
  	  		  	  		
					if (pwd.length < 6 || uid.length < 6) 
					{
						alert("Please make sure User ID and password length is min. 6!"); 
						document.formreg.txtPwd.value="";
						document.formreg.txtCpwd.value="";
						document.formreg.txtUsrnam.value="";
						document.formreg.txtUsrnam.focus;
						return false;
					}
					else if (pwd != cpwd) 
					{
						alert("Please Enter Confirm Your Password"); 
						document.formreg.txtPwd.value="";
						document.formreg.txtCpwd.value="";
						document.formreg.txtPwd.focus;
						return false;
					}
					return true;
	  	
    }
