﻿// JScript File
function isHaveSpecialChar(name)
{
 var iChars = "`~!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
     for (var i = 0; i < name.length; i++) 
         {
            //alert(iChars.indexOf(name.charAt(i)));
  	        if (iChars.indexOf(name.charAt(i))!= -1)
  	         {
  	           
  	          return true;
  	        }
          }
    return false;
         
}
function ishave(name)
{
 var iChars = "`~!@#$%^&*()+=-[]\\\';,./{}|\":<>? ";
     for (var i = 0; i < name.length; i++) 
         {
            //alert(iChars.indexOf(name.charAt(i)));
  	        if (iChars.indexOf(name.charAt(i))!= -1)
  	         {
  	           
  	          return true;
  	        }
          }
    return false;
         
}

function isStringEmpty(varInput)
{
  if(varInput==null || varInput.length==0 )
   {    return true;
   }
    return false;
 	 
         
}

function isAlphabetic(val)
{
if (val.match(/^[a-zA-Z]+$/))
{
return true;
}
else
{
return false;
} 
}

function isIntegers(s)
{   

}
function isHaveSpecialCharw(name)
{
 var iChars = "`~! #$%^&*()+=-[]\\\';,/{}|\":<>?";
     for (var i = 0; i < name.length; i++) 
         {
            //alert(iChars.indexOf(name.charAt(i)));
  	        if (iChars.indexOf(name.charAt(i))!= -1)
  	         {
  	           
  	          return false;
  	        }
  	        
          }
    return true;
         
}
//-------------------------------------------------------
function isInteger(number)
{
  return (number.toString().search(/^-?[0-9]+$/) == 0);
}

function isUnsignedInteger(s) {
return (s.toString().search(/^[0-9]+$/) == 0);
}

//---------------------------------------
 

function isZipCode(code) { 
  if(isUnsignedInteger(code))
   {
   if(code.length>6 || code.length<5)
      return false;
    else
     return true;   
   }
   else
    return false;
    
}

//---------------------------------------
function isEmail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		 var string=str.split(".");
		 
		 
		
             if (isIntegers(string[1])) {
                return true;
                
            } 
			
			
			 if(string.length>1)
		 {
			if(string[1].length==0)
				{
				return true;
				}
		 }
			
			
         
		if (str.indexOf(at)==-1){
		   
		   return true
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		 //  alert("Invalid E-mail ID")
		   return true
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    
		    return true
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    
		    return true
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    
		    return true
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    
		    return true
		 }
		
		 if (str.indexOf(" ")!=-1){
		    
		    return true
		 }
		  
		var iChars = "`~!#$%^&*()+=-[]\\\';,/{}|\":<>?";
        for (var i = 0; i < str.length; i++) 
         {
            //alert(iChars.indexOf(name.charAt(i)));
  	        if (iChars.indexOf(str.charAt(i))!= -1)
  	         {
  	           
  	          return true;
  	        }
          }
    

 		 return false					
	}
	
	   
      function hasWhiteSpace(s)
   
      {
 
           reWhiteSpace = new RegExp(/^\s+$/);
  
       
 
           // Check for white space
 
           if (reWhiteSpace.test(s)) {
   
               
   
                return false;
 
           }
 
      return true;
 
      } 

//--------------------------------------------
  
  function isUSPhoneNumber(phonenumber)
  {
  
     if(phonenumber.charAt(3)!='-' || phonenumber.charAt(7)!='-')
          {       
                  //errinfo=errinfo+'-Invalid Phone number(Ex: (9999999999) or (111-111-1111))\n'; 
              return false;
          }
      return true;    
    
   }
   
 //-------------------------------------------------  
  function isMobilenumber(phonenumber)
   {
      if(isInteger(phonenumber))
      {
	   
          if(isUnsignedInteger(phonenumber))
           {
		   
		   
                if(phonenumber.length!=10)
                {       
                  //errinfo=errinfo+'-Invalid Phone number(Ex: (9999999999) or (111-111-1111))\n'; 
                  return false;
                }
                else
                {
                  return true;
                }
           }
          else
            return false;
       }
       else 
          return false;
   
  }
    
  function hasNumbers(t)
{
var regex = /\d/g;
return regex.test(t);
}


