var iChars        =  "~!@#$%^&*()_+|`-=\\\ []{};\':\",./<>?";
var mobileChars   =  "~!@#$%^&*()_+|`-=\\\ []{};\':\",.<>?";
var addressChars  =  "~!@$%^&*()_+|`=\\[]{};\':\"<>?";

function validate_registration()
{
      	   
       if((document.patient_registration.fname.value == '' ) || (!isNaN(document.patient_registration.fname.value))) 
	   {
		   alert('Enter a valid Patients first name');
		   document.patient_registration.fname.focus();
		   return false;
	   }
	    for (var i = 0; i < document.patient_registration.fname.value.length; i++)
        {
          if (iChars.indexOf(document.patient_registration.fname.value.charAt(i)) != -1)
	      {
  		  alert ("Your Firstname has " + iChars + ". \nThese are not allowed.\n Please remove them and try again.");
		  document.patient_registration.fname.focus();
		  return false;
  	      }
        }

	   
       if((document.patient_registration.lname.value == '' ) || (!isNaN(document.patient_registration.lname.value))) 
	   {
		   alert('Enter a valid Patients last name');
		   document.patient_registration.lname.focus();
		   return false;
	   }
	    for (var i = 0; i < document.patient_registration.lname.value.length; i++)
        {
          if (iChars.indexOf(document.patient_registration.lname.value.charAt(i)) != -1)
	      {
  		  alert ("Your Lastname has " + iChars + ". \nThese are not allowed.\n Please remove them and try again.");
		  document.patient_registration.lname.focus();
		  return false;
  	      }
        }
		
		if(document.getElementById("sexm").checked==false &&  document.getElementById("sexf").checked==false )
		{
			alert("Please Select Your Gender");
			return false;
		}
		
		   if(document.patient_registration.email.value == '') 
	   {
		   alert('Enter the Email Id');
		   document.patient_registration.email.focus();
		   return false;
	   }
	   

            var str = document.patient_registration.email.value;
			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");
			   document.patient_registration.email.focus();
			   return false;
			}
	
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
			{
			   alert("Invalid E-mail ID");
			   document.patient_registration.email.focus();
			   return false;
			}
	
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
			{
			    alert("Invalid E-mail ID");
			    document.patient_registration.email.focus();
				return false;
			}
	
			 if (str.indexOf(at,(lat+1))!=-1)
			 {
				alert("Invalid E-mail ID");
			    document.patient_registration.email.focus();
				return false;
			 }
	
			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
			 {
				alert("Invalid E-mail ID");
			    document.patient_registration.email.focus();
				return false;
			 }
	
			 if (str.indexOf(dot,(lat+2))==-1)
			 {
				alert("Invalid E-mail ID");
			    document.patient_registration.email.focus();
				return false;
			 }
			
			 if (str.indexOf(" ")!=-1)
			 {
				alert("Invalid E-mail ID");
			    document.patient_registration.email.focus();
				return false;
			 } 
   

		
	   if(document.patient_registration.address.value == '') 
	   {
		   alert('Enter valid address');
		   document.patient_registration.address.focus();
		   return false;
	   }
	   for (var i = 0; i < document.patient_registration.address.value.length; i++)
        {
          if (addressChars.indexOf(document.patient_registration.address.value.charAt(i)) != -1)
	      {
  		  alert ("Your Contact Address has " + addressChars + ". \nThese are not allowed.\n Please remove them and try again.");
		  document.patient_registration.address.focus();
		  return false;
  	      }
        }
	  
		 if((document.patient_registration.mobile.value == '') || (isNaN(document.patient_registration.mobile.value)) || (document.patient_registration.mobile.value.length>10) || (document.patient_registration.mobile.value.length<10) || (document.patient_registration.mobile.value.length<=0))
	   {
		   alert('Enter the Patients valid mobile number');
		   document.patient_registration.mobile.focus()
		   return false;
	   }
	   for (var i = 0; i < document.patient_registration.mobile.value.length; i++)
        {
          if (mobileChars.indexOf(document.patient_registration.mobile.value.charAt(i)) != -1)
	      {
  		  alert ("Your Phone Number has " + mobileChars + ". \nThese are not allowed.\n Please remove them and try again.");
		  document.patient_registration.mobile.focus();
		  return false;
  	      }
        }
		if(document.getElementById('pyes').checked== false && document.getElementById('pno').checked== false)
		{
			alert("Please Select whether you registered or not ");
			return false;
		}
		if(document.getElementById('pyes').checked==true)
		{
			if(document.getElementById("pid").value=='')
			{
				alert("Please eneter your Register number");
				return false;
			}
			
		}
		
		
      
	return true;
}
function check()
{
		if(document.getElementById("pyes").checked==true)
		{
			document.getElementById("pid").value='';
			document.getElementById("pid").disabled=false;
			
		}
		if(document.getElementById("pno").checked==true)
		{
			document.getElementById("pid").disabled=true;
		}
		
}