//validation file



function checkForm(){

	if(document.frm.name.value==""){

		alert("Please enter name");

		document.frm.name.focus();

		return false;

	}



	if(document.frm.phonenumber.value==""){

		alert("Please enter phone number");

		document.frm.phonenumber.focus();

		return false;

	}



	if(document.frm.call.value==""){

		alert("Please enter best time to call");

		document.frm.call.focus();

		return false;

	}



	if(document.frm.email.value==""){

		alert("Please enter your email id");

		document.frm.email.focus();

		return false;

	}

	else{

		if (echeck(document.frm.email.value)==false){

			document.frm.email.value="";

			document.frm.email.focus();

			return false;

		}

	}



	if(document.frm.amt.value==""){

		alert("Please enter investment amount");

		document.frm.amt.focus();

		return false;

	}
	
	var objSecurityCode = document.getElementById('txtSecurityCode');           
	var var1 = document.getElementById('randomtext').value;
	
	 if(objSecurityCode.value == "" || objSecurityCode.value == null)
	 {
		alert("Plaese enter security code");
		return false;
	 }
	 if(objSecurityCode.value !=  var1)
	 {
	   alert("Security code dose not match with the text in grey box");
		return false;
	 }

}



function checkForm2(){

	if(document.frm.fname.value==""){

		alert("Please enter first name");

		document.frm.fname.focus();

		return false;

	}



	if(document.frm.lname.value==""){

		alert("Please enter last name");

		document.frm.lname.focus();

		return false;

	}



	if(document.frm.address.value==""){

		alert("Please enter address");

		document.frm.address.focus();

		return false;

	}



	if(document.frm.city.value==""){

		alert("Please enter city/state/zip");

		document.frm.city.focus();

		return false;

	}



	if(document.frm.city.value==""){

		alert("Please enter city/state/zip");

		document.frm.city.focus();

		return false;

	}



	if(document.frm.email.value==""){

		alert("Please enter your email id");

		document.frm.email.focus();

		return false;

	}

	else{

		if (echeck(document.frm.email.value)==false){

			document.frm.email.value="";

			document.frm.email.focus();

			return false;

		}

	}



	if(document.frm.call.value==""){

		alert("Please enter best time to call");

		document.frm.call.focus();

		return false;

	}
	
	var objSecurityCode = document.getElementById('txtSecurityCode');           
	var var1 = document.getElementById('randomtext').value;
	
	 if(objSecurityCode.value == "" || objSecurityCode.value == null)
	 {
		alert("Plaese enter security code");
		return false;
	 }
	 if(objSecurityCode.value !=  var1)
	 {
	   alert("Security code dose not match with the text in grey box");
		return false;
	 }

}



function echeck(str) {

		var at="@"

		var dot="."

		var lat=str.indexOf(at)

		var lstr=str.length

		var ldot=str.indexOf(dot)

		if (str.indexOf(at)==-1){

		   alert("Invalid E-mail ID")

		   return false

		}



		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){

		   alert("Invalid E-mail ID")

		   return false

		}



		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){

		    alert("Invalid E-mail ID")

		    return false

		}



		 if (str.indexOf(at,(lat+1))!=-1){

		    alert("Invalid E-mail ID")

		    return false

		 }



		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){

		    alert("Invalid E-mail ID")

		    return false

		 }



		 if (str.indexOf(dot,(lat+2))==-1){

		    alert("Invalid E-mail ID")

		    return false

		 }

		

		 if (str.indexOf(" ")!=-1){

		    alert("Invalid E-mail ID")

		    return false

		 }



 		 return true					

	}




