﻿// JScript File
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					
	}

function validation()
    {
    var  re = /^\d{1,2}\/\d{1,2}\/\d{4}$/
     
         
    if(document.getElementById("txtFirstName").value=='')
    {
    alert("Enter Firstname!");
    document.getElementById ("txtFirstName").focus();
    return false;
    }
    if(document.getElementById("txtLastName").value=='')
    {
    alert("Enter Lastname! ");
    document.getElementById ("txtLastName").focus();
    return false;
    }
//     if(document.getElementById("DropDownList1").value=='' || document.getElementById("DropDownList2").value=='' || document.getElementById("DropDownList3").value=='')
//    {
//    alert("Enter Date Of Birth(DD/MM/YYYY) !");
//    document.getElementById ("DropDownList1").focus();
//    return false;
//    
//    }
    //prangya 22may
    if(document.getElementById("DropDownList1").value=='DD' || document.getElementById("DropDownList2").value=='MM' || document.getElementById("DropDownList3").value=='YYYY')
    {
    alert("Enter Date Of Birth(DD/MM/YYYY) !");
    document.getElementById ("DropDownList1").focus();
    return false;
    
    }
//    else if ((document.getElementById("DropDownList1").value!= '' )&& (document.getElementById("DropDownList2").value!= '' )&&(document.getElementById("DropDownList3").value!= '' )&& (!document.getElementById("DropDownList1").value.match(re))&&(!document.getElementById("DropDownList2").value.match(re))&&(!document.getElementById("DropDownList3").value.match(re))))
//    { 
//    alert("Invalid date format:Enter(DD/MM/YYYY) " );
//    //+ document.getElementById("DropDownList1").value
//    document.getElementById("DropDownList1").focus();
//     return false; 
//     }
    
    if(document.getElementById("RadioBtn1_Gender").checked==false && document.getElementById("RadioBtn2_Gender").checked==false)
    {
    alert("Choose your gender! ");
    document.getElementById ("RadioBtn1_Gender").focus();
    return false;
    
    }
    
    if(document.getElementById("txtEmailAddress1").value=='')
    {
        alert("Email Address can not be blank!");
        document.getElementById("txtEmailAddress1").focus();
        return false;
        
        }
        
        else if (echeck(document.getElementById("txtEmailAddress1").value)==false)
        {
	        document.getElementById("txtEmailAddress1").focus();
		    return false
        }
    
      
    if(document.getElementById("txtMailAddress1").value=='')
    {
    alert("Enter Mailing Address! ");
    document.getElementById ("txtMailAddress1").focus();
    return false;
    
    }
          
    if((document.getElementById("txtPostalCode").value=='')||(document.getElementById("txtPostalCode").value.length < 6)||(isNaN(document.getElementById("txtPostalCode").value)))
    {
    alert("Enter Postalcode with numeric value not less then 6 characters! ");
    document.getElementById ("txtPostalCode").focus();
    return false;
    
    }
//    else if(document.getElementById("txtPostalCode").value)==false)
//		{
//	    alert("postal code must be numeric");
//	    }


    
   if ((document.getElementById("txtHomeNo").value=='')||(isNaN(document.getElementById("txtHomeNo").value)))
    {
    alert(" Enter Home number with numeric value!");
    document.getElementById ("txtHomeNo").focus();
    return false;
    
    }
    if (document.getElementById("txtMobileNo").value==''||(isNaN(document.getElementById("txtMobileNo").value)))
    {
    alert(" Enter Mobile number with numeric value!");
    document.getElementById ("txtMobileNo").focus();
    return false;
    
    }
    
    
    
    
      
    return true; 
    
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
