﻿// JScript File

var digits = "0123456789";
var phoneNumberDelimiters = "()- ";
var validWorldPhoneChars = phoneNumberDelimiters + "+";
var minDigitsInIPhoneNumber = 10;
var invalid =" ";

function CheckAlphaNumeric(e)
  {
	if(e.keyCode<'65'||e.keyCode>'90')
	{
	   if(e.keyCode<'97'||e.keyCode>'122')
	   {
	     alert("Invalid Data");
		 return false;
		} 
	 }
	 return true;
  }
 
function checkInternationalPhone(strPhone)
{
    var s=stripCharsInBag(strPhone,validWorldPhoneChars);
    return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}
function Numeric(e)
  {
	if(e.keyCode<'48'||e.keyCode>'57')
	{
	     alert("Invalid Data");
		 return false;
	}
    return true;
  }
  function digit(e)
{
    if(e.keyCode<'48' || e.keyCode>'57')
    {
        alert("No. of Room Should Be In Digit")
        return false;
    }
}
function money(e)
{
    if(e.keyCode<'48'|| e.keyCode>'57')
    {
        if(e.keyCode!='46')
        {
            alert("Invalid Data");
            return false;            
        }
    }
}
//===========================================================================================================

function UserCheck()
   {
            if(document.form1.txt_username.value=="")
              {
               alert("Please Enter your Username");
                return false;
              }  
           return true;   
   }
function registration()
{
var email=/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
var validChars1="0123456789+-";
var validChars2="0123456789+- ";
var validChars3="0123456789 ";
var strChars3;
var result3=true;
var strChars1;
var result1=true;
var strChars2;
 var result2=true; 


    if(document.form1.txt_comnm.value=="")
    {
        alert("Please enter company name");
        document.getElementById("txt_comnm").style.background="lightyellow";
        document.getElementById("txt_comnm").focus();
        return false;
    }
    if(document.form1.txt_comlocation.value=="")
    {
        alert("Please enter location");
        document.getElementById("txt_comlocation").style.background="lightyellow";
        document.getElementById("txt_comlocation").focus();
        return false;
    }
    if(document.form1.txt_comadd.value=="")
    {
        alert("Please  enter your address");
        document.getElementById("txt_comadd").style.background="lightyellow";
        document.getElementById("txt_comadd").focus();
        return false;
    }
   if(document.form1.txt_noemployee.value=="")
   {
      alert("Please Enter No of Employee");
      document.getElementById("txt_noemployee").style.background="lightyellow";
      document.getElementById("txt_noemployee").focus();
      return false;
   }
  else
  {
		     
		for(i=0;i<document.form1.txt_noemployee.value.length && result3==true;i++)
	    {
		 strChars3=document.form1.txt_noemployee.value.charAt(i);
		 if(validChars3.indexOf(strChars3)==-1)
		   {
		     alert("Only Numbers are Valid in No of Employee");
		     document.getElementById("txt_noemployee").style.background="lightyellow";
             document.getElementById("txt_noemployee").focus();
		     result3=false;
		    return result3;
		   }	         
		         	         
	    }
    }
    if(document.form1.txt_contactno.value=="")
    {
        alert("Please enter your Contact no1");
        document.getElementById("txt_contactno").style.background="lightyellow";
        document.getElementById("txt_contactno").focus();
        return false;
    }
   if(document.getElementById("txt_contactno").value!="")
	{
        var Phone=document.getElementById("txt_contactno")	
	    if (checkInternationalPhone(Phone.value)==false)
	    {
		    alert("Please Enter a Valid(min 10 digit)Contact no1");
		    document.getElementById("txt_contactno").style.backgroundColor="lightyellow";		   
		    document.getElementById("txt_contactno").focus();
		    return false;
	    }	       
	}		     
 
  if(document.getElementById("txt_contact").value!="")
	{
        var Phone=document.getElementById("txt_contact")
	
	    if (checkInternationalPhone(Phone.value)==false)
	    {
		    alert("Please Enter a Valid(min 10 digit)Contact no2");
		    document.getElementById("txt_contact").style.backgroundColor="lightyellow";		   
		    document.getElementById("txt_contact").focus();
		    return false;
	    }
	       
	}	

	   if(document.form1.txt_email.value=="")
	   {
	      alert("Insert your Email");
	      document.getElementById("txt_email").style.background="lightyellow";
         document.getElementById("txt_email").focus(); 
	       return(false);	     
	    }
	    
	    if(document.form1.txt_email.value!="")
		{
			if(!email.test(document.getElementById("txt_email").value))
			{
				alert("Invalid E-mail Address");
				document.getElementById("txt_email").style.background="lightyellow";
                document.getElementById("txt_email").focus(); 
				return (false);
			}
	    }   
	    
	
         var type= document.form1.drpdate.value;   
	    if(type=="--Years--")
         {
              alert("Please select Year");
              return false;
         } 
          
         var type= document.form1.drp_typeofbussiness.value;   
	    if(type=="Choose Item")
         {
              alert("Please select business type");
              return false;
         }        
        
        if(document.getElementById("txt_comurl").value=="")
	    {
		    alert("Please enter Company website");
		    document.getElementById("txt_comurl").style.background="lightyellow";
            document.getElementById("txt_comurl").focus(); 
			return (false);
		}		   
	    if(document.form1.txt_username.value=="")
        {
           
            alert("Please Enter LoginId");
            document.getElementById("txt_username").style.background="lightyellow";
            document.getElementById("txt_username").focus(); 
            return (false);
         }
         if(document.getElementById("txt_username").value.length>20)
         {
            alert("Login Id max 20 Characters");
            document.form1.txt_username.focus(); 
            return false;
         } 
         if(document.form1.txt_username.value!="")
         {                        
	        var validChars1="' '";
            var strChars1;
            var val="1";
            var result1=true;
            var source=document.form1.txt_username.value;
            for(i=0;i<document.form1.txt_username.value.length && result1==true;i++)
            {
               strChars1=document.form1.txt_username.value.charAt(i);
               if(validChars1.indexOf(strChars1)==1)
               {
                  alert("Spaces are not allowed in Login Id");
                  document.form1.txt_username.focus();          
                  result1=false;
                  return result1;       
               }    		         	         
            }
            
		  }		    
		  var pass= document.form1.txt_pass.value;  
		  if(pass=="")
          {
               alert("Please choose your password");
               document.getElementById("txt_pass").style.background="lightyellow";
                document.getElementById("txt_pass").focus(); 
                return (false);
           }
           else
           { 
                if(pass.length<6)
                 {
                   alert("Please choose password min six Characters");
                   document.getElementById("txt_pass").style.background="lightyellow";
                    document.getElementById("txt_pass").focus(); 
                    return (false);
                  } 
           }
}
