function validateId(strtxt,strtxt1)
{
       if(strtxt.value == "")
		{ 
			alert("Login ID can not be blank !!");
			strtxt.focus();
			return false; 
		}
		 
	  else if(strtxt1.value == "")
		{ 
			alert("Password can not be blank !!");
			strtxt1.focus();
			return false; 
		}
	 return true;	
}

function check_blank(uid,old,new1,con)
{
 if(uid.value == "")
 {
  alert("New User-Id can not be blank");
  uid.focus();
  return(false);
 }
 
 if (isNaN(uid.value.substring(0,1)) == false )
 {

  alert("First character should be an alphabet");
  uid.focus();
  return(false);
 }
 
 if(uid.value.length < 6)
 {
  alert("Minimum 6 characters for the New User-Id ");
  uid.focus();
  return(false);
 }

 if(old.value == "")
 {
  alert("Old Password can not be blank ");
  old.focus();
  return(false);
 }
 
 if(new1.value == "")
 {
  alert("New Password can not be blank ");
  new1.focus();
  return(false);
 }
 
 if (isNaN(new1.value.substring(0,1)) == false )
 {

  alert("First character should be an alphabet");
  new1.focus();
  return(false);
 }
    
 if(new1.value.length < 6)
 {
  alert("Minimum 6 characters for the New Password ");
  new1.focus();
  return(false);
 }

 if(con.value == "")
 {
  alert("Confirm Password can not be blank ");
  con.focus();
  return(false);
 }

 if (isNaN(con.value.substring(0,1)) == false )
 {

  alert("First character should be an alphabet");
  con.focus();
  return(false);
 }
 
 if(con.value.length < 6)
 {
  alert("Minimum 6 characters for the Confirm Password ");
  con.focus();
  return(false);
 }

 return(true);
}

function check_empty(old,new1,con )
{
  
 if(old.value == "")
 {
  alert("Old Password can not be blank ");
  old.focus();
  return(false);
 }
 
/* if (isNaN(old.value.substring(0,1)) == false )
 {
  	
  alert("First character should be an alphabet");
  old.focus();
  return(false);
 }
 
 if(old.value.length < 6)
 {
  alert("Minimum 6 characters for the Old Password ");
  old.focus();
  return(false);
 } */

 if(new1.value == "")
 {
  alert("New Password can not be blank ");
  new1.focus();
  return(false);
 }
    
 if (isNaN(new1.value.substring(0,1)) == false )
 {

  alert("First character should be an alphabet");
  new1.focus();
  return(false);
 }
    
 if(new1.value.length < 6)
 {
  alert("Minimum 6 characters for the New Password ");
  new1.focus();
  return(false);
 }

 if(con.value == "")
 {
  alert("Confirm Password can not be blank ");
  con.focus();
  return(false);
 }

 if (isNaN(con.value.substring(0,1)) == false )
 {

  alert("First character should be an alphabet");
  con.focus();
  return(false);
 }
 
 	
 if(con.value.length < 6)
 {
  alert("Minimum 6 characters for the Confirm Password ");
  con.focus();
  return(false);
 }
 return(true);
}

function helpmsg(str1)
{
  window.status = str1;
}

function validate(strtxt)
 {
      if (strtxt.value == "")
       {
         alert("Email ID cannot be blank");
         strtxt.focus();
         return false;
        }  
       //checks whether the email id has length less than 6 characters   
       else if  ((strtxt.value.length)<6)
        {
          alert("Your Email Id must be atleast six characters long");
          strtxt.focus();
          return false;
        }
       //checks whether the email id has length greater than 40 characters    
       else if  ((strtxt.value.length)>40)
        {
          alert("Your Email Id cannot exceed more than 40 characters");
          strtxt.focus();
          return false;
        }  
       //checks whether the first character of the email id entered is an alphabet or not   
       else if  (isNaN(strtxt.value.substring(0,1)) == false)
        {
          alert("The first character should be a alphabet");
          strtxt.focus();
          return false;
        }  
      else
      { 
        var flag;
	    {
	      flag = 0;    
	      //checks whether the @ and . characters are present or not   
	      if (strtxt.value.indexOf("@") == "-1" || strtxt.value.indexOf(".") == "-1" )
           {
              alert("Please enter E-mail address in the correct format name@yahoo.com");               
              flag = 1;
              strtxt.focus();
              return false;
   		   }
		  else
		  {
			var posfirst,poslast 
			posfirst = strtxt.value.substring(0,1)
			poslast =  strtxt.value.substring((strtxt.value.length),(strtxt.value.length-1))
			
			if( posfirst == "." || poslast == ".")
			{
			  	alert("Invalid Email Id Format !!");                 	    
				flag = 1;
				strtxt.focus();
				return false;
			}
			
		    //checks whether the . is present immediately after the @ character
			firstpos = strtxt.value.indexOf("@");
			secondpos = strtxt.value.indexOf(".");
			if (secondpos == (firstpos +1) || secondpos == (firstpos-1) ) 
			{
				alert("Invalid Email Id Format !!");                 	    
				flag = 1;
				strtxt.focus();
				return false;
			}
		  }	
	      //checks whether any of the invalid characters are entered or not
	      invalidChars = " ^&/:,;!#*";
          for (i=0; i<invalidChars.length; i++)
          {
             badChar = invalidChars.charAt(i)
             var flag1;
             
             if(strtxt.value.indexOf(badChar,0) > -1) 
              {
			     flag1 = 1;
			     flag = 1;
			   }
          }
           
           if (flag1 == 1)
           {
			  alert("Invalid Character entered in E-Mail Id");
			  strtxt.focus();
			  return false;
		   }	
       }
     }
     return true;   
} 

   
function check_valid(fname,mname,lname,ssnno,drvlic)
{
 
  /*if (assno.value == "" )
  {
	alert("Please enter Assigned Number");
	assno.focus();
	return false;
  }*/
 
  if (fname.value == "" )
  {
	alert("Please enter First name");
	fname.focus();
	return false;
  }
	
  if (mname.value == "" )
  {
	alert("Please enter Middle name");
	mname.focus();
	return false;
  }
  
    if (lname.value == "" )
  {
	alert("Please enter Last name");
	lname.focus();
	return false;
  }
  
   if (ssnno.value == "" )
  {
	alert("Please enter Social security Number");
	ssnno.focus();
	return false;
  }
  
  if (drvlic.value == "" )
  {
	alert("Please enter Driving License Number");
	drvlic.focus();
	return false;
  }
  
  if (fname != "") 
  {
   if (Chk_If_Numeric(fname) == false)
   {
     alert("Name can not be numeric !!")
     fname.focus();
     return false; 
   }
  }
  
  if (mname != "") 
  {
   if (Chk_If_Numeric(mname) == false)
   {
     alert("Name can not be numeric !!")
     mname.focus();
     return false; 
   }
  }
  
  if (lname != "") 
  {
   if (Chk_If_Numeric(lname) == false)
   {
     alert("Name can not be numeric !!")
     lname.focus();
     return false; 
   }
  }
  
  if (ssnno.value != "" )
  {
    if (Check_Valid_SSN(ssnno)== false)
    {
      return false;
    }
  }  
  
  
  return true;  
}   


function Chk_Phone(Home,Bus,Ext,Fax1,Fax2,mobile,pager,Mail1,Mail2)
{
  
  if (Bus.value == "") 
  {
    alert("Business Phone can not be blank !!"); 
    Bus.focus();
    return false;
  }
  if (Home != "") 
  {
   if (Chk_numeric(Home) == false)
   {
     return false;
   }
  }
  
  if (Bus != "") 
  {
   if (Chk_numeric(Bus) == false)
   {
	return false;
   }	
  }
  
  if (Ext != "") 
  {
    if (Chk_numeric(Ext) == false)
    {
	 return false;
    }
  }
  
  if (Fax1 != "") 
  {
   if(Chk_numeric(Fax1) == false)
   {
	return false;
   }
   
  }
  if (Fax2 != "") 
  {
   if(Chk_numeric(Fax2) == false)
   {
	return false;
   }
  }
  
  if (mobile != "") 
  {
   if(Chk_numeric(mobile) == false)
    {
	 return false;
    }  
  }
  
  if (pager != "") 
  {
    if(Chk_numeric(pager) == false)
    {
	  return false;
    }  
  }
  if (Mail1 != "")
  {
    if (validate(Mail1) == false)
    {
     return false;
    }
  }
  
  if (Mail2 != "")
  {
    if (validate(Mail2) == false)
    {
     return false;
    }
  }
  return true; 
}

function Chk_numeric(fld)
{
 if (fld.value != "" )
  {
    var i;
	for(i=0;i<fld.value.length;i++)
	{
	  if (isNaN(fld.value.substring(i,1)) ==  true )
		{
			alert("Please enter numeric Data");
			fld.focus();
			return(false);
		 }	
	}	
  }
 return true;
}

function Chk_If_Numeric(fld)
{
 if (fld.value != "" )
  {
    var i;
	for(i=0;i<fld.value.length;i++)
	{
	  if (isNaN(fld.value.substring(i,1))== true )
	  {
	 	return true;
	  }	
	  else
	  {
	    return false;
	  }
	}	
  }
 return true;
}


function chkdate(in_val)
{
   if (in_val.value !="")
	{
    var first_dash= 0;
    var second_dash = 0;
    if (in_val.value.charAt(2) != "/" ||
        in_val.value.charAt(5) != "/" ||
        in_val.value.length != 10 )
    {
        alert("Date not in valid format - Enter date in MM/DD/YYYY format ");
        in_val.value="";
        in_val.focus();
        return(false);
    }
    first_dash = in_val.value.indexOf("/");
    second_dash = in_val.value.lastIndexOf("/")    ;
    mm = in_val.value.substring(0,first_dash);
    dd = in_val.value.substring(first_dash+1,second_dash);
    yy = in_val.value.substring(second_dash+1,in_val.value.length);
    if (isNaN(dd) || isNaN(mm) || isNaN(yy))                                    
    {                                                                           
        alert("Not a valid Month/Date/Year.Month/Date/Year should be Integers.");                                                                              
        in_val.value="";                                                        
        in_val.focus();                                                         
        return(false);                                                          
    }                                                                           
    else                                                                        
    {                                                                           
        null;                                                                   
    }                                                                           
    chkleap = 0;
    if (dd <=0 || dd > 31 ||  mm <= 0 || mm > 12 )
    {
        alert("Invalid MMth/Day/Year ");
        in_val.value="";
        in_val.focus();
        return (false);
    }
    if (yy < 1900 || yy > 2099)
    {
        alert("Year should be between 1900 and 2099");
        in_val.value="";
        in_val.focus();
        return (false);
    }
    if( !(yy%400) ||  (!(yy%4) && (yy%100)))
    {
        chkleap = 1;
    }
    if (mm == 4 || mm == 6 || mm == 9 || mm == 11)
    {
        if (dd>30)
        {
            alert("Incorrect Day of the MMth");
            in_val.value="";
            in_val.focus();
            return (false);
        }
    }
    if (mm == 2)
    {
        if (dd > 29 || (chkleap != 1 && dd > 28) )
        {
            alert("Incorrect Day of the MMth");
            in_val.value="";
            in_val.focus();
            return (false);
        }
    }
  }
}

function Check_Valid_SSN(fld){
  
	if (fld.value.indexOf("-") == "-1" )
	{
		alert("Enter Data In ###-###-#### format");                 	    
		fld.focus();
		return false;
	}	else	{
		var ssnarr=fld.value.split("-")		if (ssnarr.length < 3)		{
			alert("Enter Data In ###-###-#### format");                 	    
			fld.focus();
			return false;
		}		if (ssnarr[0].length != 3)
		{ 
			alert("Enter Data In ###-###-#### format");                 	    
			fld.focus();
			return false;
		}
		if (ssnarr[1].length != 3)
		{ 
			alert("Enter Data In ###-###-#### format");                 	    
			fld.focus();
			return false;
		}		if (ssnarr[2].length != 4)
		{ 
			alert("Enter Data In ###-###-#### format");                 	    
			fld.focus();
			return false;
		}
				for(i=0;i<=2;i++)		{
		 if (isNaN(ssnarr[i]) ==  true )
		 {
		 	alert("Please enter Numeric Data for the SSN number");
			fld.focus();
			return(false);
		 }	
		} 
	    return true;	
	}}

function check_valid_first(fname,mname,lname,ssnno,assno,drvlic)
{
 
  if (assno.value == "" )
  {
	alert("Please enter Assigned Number");
	assno.focus();
	return false;
  }
 
  if (fname.value == "" )
  {
	alert("Please enter First name");
	fname.focus();
	return false;
  }
	
  if (mname.value == "" )
  {
	alert("Please enter Middle name");
	mname.focus();
	return false;
  }
  
    if (lname.value == "" )
  {
	alert("Please enter Last name");
	lname.focus();
	return false;
  }
  
   if (ssnno.value == "" )
  {
	alert("Please enter Social security Number");
	ssnno.focus();
	return false;
  }
  
  if (drvlic.value == "" )
  {
	alert("Please enter Driving License Number");
	drvlic.focus();
	return false;
  }
  
  if (fname != "") 
  {
   if (Chk_If_Numeric(fname) == false)
   {
     alert("Name can not be numeric !!")
     fname.focus();
     return false; 
   }
  }
  
  if (mname != "") 
  {
   if (Chk_If_Numeric(mname) == false)
   {
     alert("Name can not be numeric !!")
     mname.focus();
     return false; 
   }
  }
  
  if (lname != "") 
  {
   if (Chk_If_Numeric(lname) == false)
   {
     alert("Name can not be numeric !!")
     lname.focus();
     return false; 
   }
  }
  
  if (ssnno.value != "" )
  {
    if (Check_Valid_SSN(ssnno)== false)
    {
      return false;
    }
  }  
  
  
  return true;  
}   











