<!-- $Header: IKN_Input_Fields.js 1.00 14-Aug-2008 pavan_kondaveeti@infosys.com $ -->
/**********************************************************************************************
 *  PROPRIETARY/CONFIDENTIAL                                                               
 *  Copyright (c) 2008 IKON OFFICE SOLUTIONS
 *                                                                                          
 *  All rights reserved.
 *                                                                                          
 * Type        : Javascript file                                                                     
 * Name        : IKN_Input_Fields.js
 * Description : To validate the input fields of ASP pages.
 *                
 **********************************************************************************************/
 
 // function for validating inputs in requestinfoRemlox.asp
 
 //************************************************************************
 //** Name            : fnValidateInputname
 //** Description     : Calls validation functions for name
 //**
 //** Called from     : Form
 //** Pages	     : requestinfoRemlox.asp
 //************************************************************************/
 
 function fnValidateInputname()
 {
  	if(document.rfiForm.reqName.value != "") 
 		
 	{ 
 	
 		if(!fnValidateName(document.rfiForm.reqName.value))
 		{
 			 rfiForm.reqName.focus();
 			
 			 alert("Please enter a valid Name.\nPlease avoid special characters like '#','*','%'");
 			 document.rfiForm.reqName.value = "";
 			 
 		}
 	}
 	
}
 
 //************************************************************************
 //** Name            : fnValidateTitle
 //** Description     : Calls validation functions for fields of form
 //**
 //** Called from     : Form
 //** Pages	      : requestinfoRemlox.asp
 //************************************************************************
 function fnValidateTitle()
 {
 
 	if(document.rfiForm.Title.value != "") 
 		
 	{	
 		if(!fnValidateCompany(document.rfiForm.Title.value))
 		{
 			rfiForm.Title.focus();
 			document.rfiForm.Title.value = "";
 			alert("Please enter a valid Title.\nPlease avoid special characters like '#','*','%'");		
 			
 		}
 	}
 
}

//************************************************************************
//** Name            : fnValidateCompanyName
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : requestinfoRemlox.asp
//************************************************************************
function fnValidateCompanyName()
{

	if(document.rfiForm.CompanyName.value != "") 
			
	{
		if(!fnValidateCompany(document.rfiForm.CompanyName.value))
		{
			rfiForm.CompanyName.focus();
			document.rfiForm.CompanyName.value = "";
			alert("Please enter a valid Company/Organization.\nPlease avoid special characters like '#','*','%'");				
			
		}
	}


}

//************************************************************************
//** Name            : fnValidatecity
//** Description     : Calls validation functions for  cit name
//**
//** Called from     : Form
//** Pages	     : requestinfoRemlox.asp
//************************************************************************

function fnValidateState()
{
	if(document.rfiForm.State.value != "") 
		
	{
		if(!fnValidateCityName(document.rfiForm.State.value))
		{
			rfiForm.State.focus();
			alert("Please enter a valid State Name.\nPlease avoid special characters like '#','*','%'");	
			document.rfiForm.State.value = "";
			
		}
	}

}

// function for validating inputs in requestForm.asp



//************************************************************************
//** Name            : fnValidatefirstname
//** Description     : Calls validation functions for firstname
//**
//** Called from     : Form
//** Pages	     : requestForm.asp
//************************************************************************

function fnValidatefirstname()
{

	if(document.form1.firstname.value != "") 
		
	{ 
	
		if(!fnValidateName(document.form1.firstname.value))
		{
			 form1.firstname.focus();
			
			 alert("Please enter a valid First Name.\nPlease avoid special characters like '#','*','%'");
			 document.form1.firstname.value = "";
			 
		}
	}
	
}

//************************************************************************
//** Name            : fnValidatelastname
//** Description     : Calls validation functions for last name
//**
//** Called from     : Form
//** Pages	     : requestForm.asp
//************************************************************************

function fnValidatelastname()
{
	if(document.form1.lastname.value != "") 
		
	{

		if(!fnValidateName(document.form1.lastname.value))
		{			
			form1.lastname.focus();
			alert("Please enter a valid Last Name.\nPlease avoid special characters like '#','*','%'");
			document.form1.lastname.value = "";
			
		}
	}
	

}

//************************************************************************
//** Name            : fnValidatecompany
//** Description     : Calls validation functions for company name
//**
//** Called from     : Form
//** Pages	     : requestForm.asp
//************************************************************************
function fnValidatecompany()
{
	if(document.form1.company.value != "") 
		
	{

		if(!fnValidateCompany(document.form1.company.value))
		{
			form1.company.focus();
			alert("Please enter a valid Company Name.\nPlease avoid special characters like '#','*','%'");	
			document.form1.company.value = "";
			
		}
	}
	
}

//************************************************************************
//** Name            : fnValidateaddress
//** Description     : Calls validation functions for street address
//**
//** Called from     : Form
//** Pages	     : requestForm.asp
//************************************************************************

function fnValidateaddress()
{
	if(document.form1.address.value != "") 
		
	{

		if(!fnValidateAddress(document.form1.address.value))
		{
			form1.address.focus();
			alert ("Please enter a valid Street Address.\nPlease avoid special characters like '?','*','%'");
			document.form1.address.value = "";
			
		}
	}
	
}

//************************************************************************
//** Name            : fnValidateaddress2
//** Description     : Calls validation functions for address (cont)
//**
//** Called from     : Form
//** Pages	     : requestForm.asp,requestinfoRemlox.asp
//************************************************************************

function fnValidateaddress2()
{
	if(document.form1.address2.value != "") 
			
	{
		if(!fnValidateAddress(document.form1.address2.value))
		{
			form1.address2.focus();
			alert ("Please enter a valid Address.\nPlease avoid special characters like '?','*','%'");
			document.form1.address2.value = "";
			
		}
	}

}

//************************************************************************
//** Name            : fnValidatecity
//** Description     : Calls validation functions for  cit name
//**
//** Called from     : Form
//** Pages	     : requestForm.asp,requestinfoRemlox.asp
//************************************************************************

function fnValidatecity()
{
	if(document.form1.city.value != "") 
		
	{
		if(!fnValidateCityName(document.form1.city.value))
		{
			form1.city.focus();
			alert("Please enter a valid City Name.\nPlease avoid special characters like '#','*','%'");	
			document.form1.city.value = "";
			
		}
	}

}

//************************************************************************
//** Name            : fnValidatezip
//** Description     : Calls validation functions for zip code
//**
//** Called from     : Form
//** Pages	     : requestForm.asp
//************************************************************************

function fnValidatezip()
{	
	if(document.form1.zip.value != "") 
		
	{
		if(!fnValidateZipCode(document.form1.zip.value))
		{
			form1.zip.focus();
			document.form1.zip.value = "";
			
		}
	}

}

//************************************************************************
//** Name            : fnValidateemail
//** Description     : Calls validation functions for email
//**
//** Called from     : Form
//** Pages	     : requestForm.asp
//************************************************************************
function fnValidateemail()
{

	if(document.form1.email.value != "") 
		
	{
		if(!fnValidateEmailId(document.form1.email.value))
		{

			form1.email.focus();
			document.form1.email.value = "";
			
		}

	}
	
}

//************************************************************************
//** Name            : fnValidateareacode
//** Description     : Calls validation functions for areacode
//**
//** Called from     : Form
//** Pages	     : requestForm.asp
//************************************************************************
function fnValidateareacode()
{
	if(document.form1.areacode.value != "") 
			
	{
		if(!fnValidatePhone(document.form1.areacode.value))
		{		
			form1.areacode.focus();
			document.form1.areacode.value ="";
			
		}
	}

}

//************************************************************************
//** Name            : fnValidatephone
//** Description     : Calls validation functions for phone
//**
//** Called from     : Form
//** Pages	     : requestForm.asp,requestinfoRemlox.asp
//************************************************************************

function fnValidatephone()
{

	if(document.form1.phone.value != "") 
		
	{
		if(!fnValidatePhone(document.form1.phone.value))
		{		
			form1.phone.focus();
			document.form1.phone.value = "";
			
		}
	}


}		




// function for validating inputs in  howToBuy.asp , askIkon.asp and requestInfo.asp






//************************************************************************
//** Name            : fnValidateFirstName
//** Description     : Calls validation functions for first name
//**
//** Called from     : Form
//** Pages	     : howToBuy.asp, requestInfo.asp, askIKON.asp
//************************************************************************


function fnValidateFirstName()
{

	if(document.rfiForm.FirstName.value != "") 
	
	{
		if(!fnValidateName(document.rfiForm.FirstName.value))
		{
			rfiForm.FirstName.focus();
			document.rfiForm.FirstName.value = "";
			alert ("Please enter a valid First Name.\nPlease avoid special characters like '#','*','%'");
			
						
		}
	}

}

//************************************************************************
//** Name            : fnValidateLastName
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : howToBuy.asp, requestInfo.asp, askIKON.asp
//************************************************************************

function fnValidateLastName()
{

	if(document.rfiForm.LastName.value != "") 

	
	{
		if(!fnValidateName(document.rfiForm.LastName.value))
		{
			rfiForm.LastName.focus();
			document.rfiForm.LastName.value = "";
			alert("Please enter a valid Last Name.\nPlease avoid special characters like '#','*','%'");
			
		}
	}
	
}


//************************************************************************
//** Name            : fnValidateJobTitle
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : howToBuy.asp, requestInfo.asp, askIKON.asp
//************************************************************************
function fnValidateJobTitle()
{

	if(document.rfiForm.JobTitle.value != "") 
		
	{	
		if(!fnValidateCompany(document.rfiForm.JobTitle.value))
		{
			rfiForm.JobTitle.focus();
			document.rfiForm.JobTitle.value = "";
			alert("Please enter a valid JobTitle.\nPlease avoid special characters like '#','*','%'");		
			
		}
	}

}


//************************************************************************
//** Name            : fnValidateCompanyName
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : howToBuy.asp, requestInfo.asp, askIKON.asp
//************************************************************************
function fnValidateCompanyName()
{

	if(document.rfiForm.CompanyName.value != "") 
			
	{
		if(!fnValidateCompany(document.rfiForm.CompanyName.value))
		{
			rfiForm.CompanyName.focus();
			document.rfiForm.CompanyName.value = "";
			alert("Please enter a valid Company Name.\nPlease avoid special characters like '#','*','%'");				
			
		}
	}


}


//************************************************************************
//** Name            : fnValidateAddress1
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : howToBuy.asp, requestInfo.asp, askIKON.asp,
//**				requestinfoRemlox.asp
//************************************************************************
function fnValidateAddress1()
{

	if(document.rfiForm.Address1.value != "") 
			
	{	
		if(!fnValidateAddress(document.rfiForm.Address1.value))
		{
			rfiForm.Address1.focus();
			document.rfiForm.Address1.value = "";
			alert ("Please enter a valid Street Address.\nPlease avoid special characters like '?','*','%'");
			
		}
	}
	
}


//************************************************************************
//** Name            : fnValidateAddress2
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : howToBuy.asp, requestInfo.asp, askIKON.asp
//************************************************************************
function fnValidateAddress2()
{

	if(document.rfiForm.Address2.value != "") 
				
	{
		if(!fnValidateAddress(document.rfiForm.Address2.value))
		{
			rfiForm.Address2.focus();
			document.rfiForm.Address2.value = "";
			alert ("Please enter a valid Address.\nPlease avoid special characters like '?','*','%'");
			
		}
	}

}


//************************************************************************
//** Name            : fnValidateCity
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : howToBuy.asp, requestInfo.asp, askIKON.asp
//************************************************************************
function fnValidateCity()
{

	if(document.rfiForm.City.value != "") 
			
	{
		if(!fnValidateCityName(document.rfiForm.City.value))
		{
			rfiForm.City.focus();
			document.rfiForm.City.value = "";
			alert("Please enter a valid City Name.\nPlease avoid special characters like '?','*','%'");						
			
		}
	}

}


//************************************************************************
//** Name            : fnValidateZip
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : howToBuy.asp, requestInfo.asp, askIKON.asp
//************************************************************************
function fnValidateZip()
{

	if(document.rfiForm.Zip.value != "") 
			
	{
		if(!fnValidateZipCode(document.rfiForm.Zip.value))
		{	
			rfiForm.Zip.focus();
			document.rfiForm.Zip.value = "";
		}
	}

}


//************************************************************************
//** Name            : fnValidateEmail
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : howToBuy.asp, requestInfo.asp, askIKON.asp,
//**				
//************************************************************************
function fnValidateEmail()
{

	if(document.rfiForm.Email.value != "") 
			
	{
		if(!fnValidateEmailId(document.rfiForm.Email.value))
		{

			rfiForm.Email.focus();
			document.rfiForm.Email.value = "";
			
		}
	}

}

//************************************************************************
//** Name            : fnValidateEmailRemlox
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : requestinfoRemlox.asp
//************************************************************************
function fnValidateEmailRemlox()
{
	if(document.rfiForm.Email.value != "") 
			
	{
		if(!fnValidateEmailIdRemlox(document.rfiForm.Email.value))
		{

			rfiForm.Email.focus();
			document.rfiForm.Email.value = "";
			
		}
	}

}


function fnValidateEmailIdRemlox(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var regexLetter = /[^a-zA-Z0-9-_\.@]/;
		var CharPos = str.search(regexLetter);
		if ( (CharPos >= 0)) { 
			alert("Please Enter a valid Email.\nPlease avoid special characters like '^','*','%','#','$'");
			return false;
		}
		if (str.indexOf(at)==-1){
		   alert("Please Enter a valid Email")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please Enter a valid Email")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please Enter a valid Email")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please Enter a valid Email")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please Enter a valid Email")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please Enter a valid Email")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please Enter a valid Email")
		    return false
		 }

 		 return true					
	}
//************************************************************************
//** Name            : fnValidateAreaCode
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : howToBuy.asp, requestInfo.asp, askIKON.asp
//************************************************************************
function fnValidateAreaCode()
{

	if(document.rfiForm.AreaCode.value != "") 
			
	{
		if(!fnValidatePhone(document.rfiForm.AreaCode.value))
		{		
			rfiForm.AreaCode.focus();
			document.rfiForm.AreaCode.value = "";
			
		}
	}

}


//************************************************************************
//** Name            : fnValidatePhone1
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : howToBuy.asp, requestInfo.asp, askIKON.asp
//************************************************************************
function fnValidatePhone1()
{
	if(document.rfiForm.Phone1.value != "") 
			
	{
		if(!fnValidatePhone(document.rfiForm.Phone1.value))
		{		
			rfiForm.Phone1.focus();
			document.rfiForm.Phone1.value = "";
		}
	
	}
	

}

//************************************************************************
//** Name            : fnValidatePhone2
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : howToBuy.asp, requestInfo.asp, askIKON.asp
//************************************************************************
function fnValidatePhone2()
{	
	if(document.rfiForm.Phone2.value != "") 
			
	{
		if(!fnValidatePhone(document.rfiForm.Phone2.value))
		{		
			rfiForm.Phone2.focus();
			document.rfiForm.Phone2.value = "";
		}
	}

}

//************************************************************************
//** Name            : fnValidatePhoneExt
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : howToBuy.asp, requestInfo.asp, askIKON.asp
//************************************************************************
function fnValidatePhoneExt()
{
	if(document.rfiForm.PhoneExt.value != "") 
			
	{
	
		if(!fnValidatePhone(document.rfiForm.PhoneExt.value))
		{		
			rfiForm.PhoneExt.focus();
			document.rfiForm.PhoneExt.value = ""; 
		}
	}

}

//************************************************************************
//** Name            : fnValidateComments
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : howToBuy.asp, requestInfo.asp, askIKON.asp
//************************************************************************
function fnValidateComments()
{
	
	if(document.rfiForm.Comments.value != "") 
			
	{	
		if(!fnValidateCommentsText(document.rfiForm.Comments.value))
		{
			rfiForm.Comments.focus();
			document.rfiForm.Comments.value = "";			
			alert("Please enter Comments without special characters like '^','*','%'.");	
			
		}
	}							

	
}


//************************************************************************
//** Name            : fnValidateq1
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : search.asp
//************************************************************************


function fnValidateq1()
{

	if(document.form.q1.value != "") 
	
	{
	
		if(!fnValidateSearch(document.form.q1.value))
		{
					
			alert("Please search without special characters like '^','*','%'.");
			document.form.q1.value = "";
			form.q1.focus();
			return false;
		}
		else 
		{
			return true;
		
		}
	}
	
}


//************************************************************************
//** Name            : fnValidateSiteSearch
//** Description     : Calls validation functions for fields of form
//**
//** Called from     : Form
//** Pages	     : pageHead.asp
//************************************************************************


function fnValidateSiteSearch()
{



	if(document.siteSearch.q1.value != "") 
	
	{
		if(!fnValidateSearch(document.siteSearch.q1.value))
		{
			siteSearch.q1.focus();
			alert("Please search without special characters like '^','*','%'.");
			document.siteSearch.q1.value = "";
			return false;
			
			
		}
		else
		{		
			document.siteSearch.submit();
			return true;
		}
	}


}

// End Of File
