﻿// JScript File
function postvalidate()
{
    if(document.getElementById("Select1").value=="0")
    {
       alert("Please select property type");
       document.getElementById("Select1").focus();
       return false;
    }
    if(document.getElementById("Select2").value=="0")
    {
       alert("Please select city");
       document.getElementById("Select2").focus();
       return false;
    }
    if(document.getElementById("TxtName").value=="")
    {
       alert("Please enter your name");
       document.getElementById("TxtName").focus();
       return false;
    }
    if(document.getElementById("TxtMobile").value=="")
    {
        alert("Please enter mobile no.");
       document.getElementById("TxtMobile").focus();
       return false;
    }
   y=document.getElementById("TxtMobile").value;
    if(isNaN(y)||y.indexOf(" ")!=-1)
        {
            alert("Enter numeric value");
            document.getElementById("TxtMobile").focus();
            return false;  
         }
         if(y != "")
         {
            if (y.length>10 || y.length<10)
            {
                alert("enter 10 characters");
                document.getElementById("TxtMobile").focus();
                return false;
            }
          
    if (y.charAt(0)!="9")
       {
            alert("it should start with 9 ");
             document.getElementById("TxtMobile").focus();
             return false;
        }
     } 
       
//    z=document.getElementById("TxtPhone").value;
//    
//    if(isNaN(z)||z.indexOf(" ")!=-1)
//        {
//            alert("Enter numeric value");
//            document.getElementById("TxtPhone").focus();
//            return false;  
//         }
//         if(z.lenght != 0)
//         {
//            if (z.length>5)
//            {
//                alert("enter 5 digits only");
//                document.getElementById("TxtPhone").focus();
//                return false;
//            }
//          }
//          
//          
//     if(document.getElementById("TxtPhone").value!="" && document.getElementById("TxtPhone1").value=="")
//    {
//        alert("Please enter both area code and phone number");
//       document.getElementById("TxtPhone1").focus();
//       return false;
//    }    
//    
//     if(document.getElementById("TxtPhone").value=="" && document.getElementById("TxtPhone1").value!="")
//    {
//        alert("Please enter both area code and phone number");
//       document.getElementById("TxtPhone").focus();
//       return false;
//    }     
//    
//      
//        
//    x=document.getElementById("TxtPhone1").value;
//    if(isNaN(x)||x.indexOf(" ")!=-1)
//    {
//       alert("Enter correct phone number");
//       document.getElementById("TxtPhone1").focus();
//       return false;  
//    }
    //Check for EmailId validation
    var str=document.getElementById("TxtMail").value;
    var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if(str=="")
	{
	    alert("Please enter Your EmailId");
	    document.getElementById("TxtMail").focus();
	   return false;
	}
	if (str.indexOf(at)==-1){
	   alert("Invalid E-mail ID");
	   document.getElementById("TxtMail").focus();
	   return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid E-mail ID");
	   document.getElementById("TxtMail").focus();
	   return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    alert("Invalid E-mail ID");
	    document.getElementById("TxtMail").focus();
	    return false;
	}
	 if (str.indexOf(at,(lat+1))!=-1){
	    alert("Invalid E-mail ID");
	    document.getElementById("TxtMail").focus();
	    return false;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    alert("Invalid E-mail ID");
	    document.getElementById("TxtMail").focus();
	    return false;
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    alert("Invalid E-mail ID");
	    document.getElementById("TxtMail").focus();
	    return false;
	 }
		
	 if (str.indexOf(" ")!=-1){
	    alert("Invalid E-mail ID");
	    document.getElementById("TxtMail").focus();
	    return false;
	 }
	/*if(document.getElementById("TxtDescription").value=="")
    {
       alert("Please type description about your requirement");
       document.getElementById("TxtDescription").focus();
       return false;
    } */ 
}

