

// Form Validation for Registration with Us
// Form Validation for Registration with Us
// Form Validation for Registration with Us



function validate()
{
	
		///*validation First Name field*///

		if (document.queryform.name.value=="")
		{
		 alert("Please enter your Name.")
	     document.queryform.name.focus();
		  return false;
	   	}
		
	 	if(document.queryform.name.value!="")
		{
		var alphaExp = /^[a-zA-Z""]+$/; 
		 if(document.queryform.name.value.search(alphaExp)==-1)
		 {
        	 alert("Invalid character in Name field.")
	   		document.queryform.name.value="";
			document.queryform.name.focus();

		   return false;
			 }
		 }

		
	   
         /*validation email field*/
		 
		 
 var emailID=document.queryform.email
	
	if ((emailID.value==null)||(emailID.value==""))
	{
		alert("E-mail ID  is blank, please fill it.")
		document.emailID.value="";
		emailID.focus()
		  return false;
	}
	if (echeck(emailID.value)==false)
	{
		emailID.value=""
			alert("Please enter your E-mail ID in right format.")
		emailID.focus()
		  return false;
	}
		
		
		
		
		///*validation Select City field*///

		if (document.queryform.city.selectedIndex == 0)
		{
		 alert("Please Select City Name.")
	     document.queryform.city.focus();
		  return false;
	   	}
		
		
		
	 
	 /*validation Phone field*/
	if(document.queryform.Phone.value=="")
		{
		 alert("Please enter your Phone Number.");
		 	   		document.queryform.Phone.value="";
		   document.queryform.Phone.focus();
		  return false;

		}
		
		if(document.queryform.Phone.value!="")
		{
		var telechk = /^[" "0-9+()-]+$/;
		 if(document.queryform.Phone.value.search(telechk)== -1)
		 	{
		 alert("Invalid Phone Number.");
		document.queryform.Phone.value="";
	  	document.queryform.Phone.focus();
		return false;

			}
		}
		
		
}
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
        var loc;
        var pos;        
		
		loc=(str.search(/@/));
	    pos=(str.slice(0,loc));
		
        if(!isNaN(pos))
		{
		alert("Invalid Email ID ")
		   return false
		}
	   
		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					
	}
	
	