
  function checkformhome(){
	var Invalid=" ";
	var frm = document.formhome;
	
	if(frm.fname1.value=="" || frm.fname1.value=="First Name"){
		alert("Please enter your First name");
		frm.fname1.focus();
		return false;
	}
	else {
		if(!hasWhiteSpace(frm.fname1.value))
			{
				frm.fname1.value="";
				frm.fname1.focus();
				return false;
			}
	}
/*	if(frm.lname1.value=="" || frm.lname1.value=="Last Name"){
		alert("Please enter your Last name");
		frm.lname1.focus();
		return false;
	}
	else {
		if(!hasWhiteSpace(frm.lname1.value))
			{
				frm.lname1.value="";
				frm.lname1.focus();
				return false;
			}
	}
  */
	if(frm.emailhome.value==""){
		alert("Please enter your email id");
		frm.emailhome.focus();
		return false;
	}
else {
		if(!hasWhiteSpace(frm.emailhome.value))
 {
	 frm.emailhome.value="";
				frm.emailhome.focus();
  return false;
   }
	
if (frm.emailhome.value.indexOf(Invalid) > -1)
 {
alert("Sorry, spaces are not allowed.");
frm.emailhome.value="";
frm.emailhome.focus();
return false;
}

	var str = frm.emailhome.value;
	if(!emailCheck(str)){
		frm.emailhome.focus();
		return false;
	}
}

/*	if(frm.comment.value=="" || frm.comment.value=="Message"){
		alert("Please type your message");
		frm.comment.focus();
		return false;
	}
	else {
		if(!hasWhiteSpace(frm.comment.value))
 {
			frm.comment.value="";
			frm.comment.focus();
  return false;
   }
	}*/
	if(frm.txt_captcha.value=="" || frm.txt_captcha.value=="Verification code"){
		alert("Please enter the captcha code");
		frm.txt_captcha.focus();
		return false;
	}


//if(frm.security_code.value==""){
//		alert("Please enter security code as shown in graphic");
//		frm.security_code.focus();
//		return false;
//	}
}
function hasWhiteSpace(s)
      {
     reWhiteSpace = new RegExp(/^\s+$/);
           // Check for white space
           if (reWhiteSpace.test(s)) {
                alert("Sorry, Spaces are not allowed");
                return false;
           }
      return true;
      } 

//validation for email
function emailCheck(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("Enter the valid e-mail id !")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){           
            alert("Enter the valid e-mail id")
		    return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			alert("Enter the valid e-mail id");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
			alert("Enter the valid e-mail id");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			alert("Enter the valid e-mail id");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			alert("Enter the valid e-mail id");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Enter the valid e-mail id !");
		    return false;
		 }
 		 return true					
}

