// JavaScript Document
//zip code validation
function validfn(fnm)
  {
  fnlen=fnm.length
  	if (fnlen == 0)
  	{alert("First name is required")
  	document.dataentry.fn.focus()}
  }
//end zip code validation
//----------phone number validation-------------
	
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 1;

	function isInteger(s)
	{   var i;
	for (i = 0; i < s.length; i++)
	{   
	// Check that current character is number.
	var c = s.charAt(i);
	if (((c < "0") || (c > "9"))) return false;
	}
	// All characters are numbers.
	return true;
	}

	function stripCharsInBag(s, bag)
	{   var i;
		var returnString = "";
		// Search through string's characters one by one.
		// If character is not in bag, append to returnString.
		for (i = 0; i < s.length; i++)
			{   
			// Check that current character isn't whitespace.
				var c = s.charAt(i);
				if (bag.indexOf(c) == -1) returnString += c;
				}
			return returnString;
			}
	function checkInternationalPhone(strPhone){
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
	}

//----------phone number validation-------------
	
function validuser()
{
	var obj=document.form1;
	digits="0123456789" //degits
   
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj.email.value)))
	{
		alert("Invalid Email Address! Please re-enter!")
		obj.email.focus();
		obj.email.select();
		
		return false;
	}
	if(obj.name.value=="")
	{
		alert("Billing name can not be left blank!");
		obj.name.focus();
		return false;
	}
	if(parseInt(obj.hacctype.value)!=1)
	{		   
		if(obj.company.value=="")
		{
			alert("Billing company can not be left blank!");
			obj.company.focus();
			return false;
		}
	}
	if(obj.country.value=="0")
	{
		alert("Billing country can not be left blank!");
		obj.country.focus();
		return false;
	}
	if(obj.street1.value=="")
	{
		alert("Billing street can not be left blank!");
		obj.street1.focus();
		return false;
	}
	if(obj.city.value=="")
	{
		alert("Billing city can not be left blank!");
		obj.city.focus();
		return false;
	}
	if(obj.state.value=="0")
	{
		alert("Billing state can not be left blank!");
		obj.state.focus();
		return false;
	}
	if(obj.zip.value=="")
	{
		alert("Billing zip code can not be left blank!");
		obj.zip.focus();
		return false;
	}
	if(obj.zip.value.length!=5)
	{
		alert("Please fill billing zip code with 5 characters!");
		obj.zip.focus();
		return false;
	}
	for(i=0; i<5; i++)
   	{
		if (digits.indexOf(obj.zip.value.charAt(i))<0)
    	{	
		 alert("Please enter numeric value for billing zip code!")
    	 obj.zip.focus();
		 obj.zip.select();
		 return false;
		}
		
     }
	if( (obj.zip2.value!="") && (obj.zip2.value.length!=4) )
	{
		alert("Fill billing Zip+4 code with 4 characters or leave it blank!");
		obj.zip2.focus();
		return false;
	}
	for(i=0; i<4; i++)
   	{
		if (digits.indexOf(obj.zip2.value.charAt(i))<0)
    	{	
		 alert("Please enter numeric value for billing Zip+4")
    	 obj.zip2.focus();
		 obj.zip2.select();
		 return false;
		}
		
     }
	if ((obj.phone1.value==null)||(obj.phone1.value=="")){
		alert("Please enter a valid 10 digit phone number for billing!")
		obj.phone1.focus();
		return false;
	}
	if (checkInternationalPhone(obj.phone1.value)==false){
		alert("Please enter a valid 10 digit phone number for billing!")
		obj.phone1.select();
		obj.phone1.focus();
		return false;
	}
	if(obj.phone1.value.length!=3)
	{
		alert("Please enter a valid 10 digit phone number for billing!");
		obj.phone1.focus();
		return false;
	}
	if ((obj.phone2.value==null)||(obj.phone2.value=="")){
		alert("Please enter a valid 10 digit phone number for billing!")
		obj.phone2.focus();
		return false;
	}
	if (checkInternationalPhone(obj.phone2.value)==false){
		alert("Please enter a valid 10 digit phone number for billing!")
		obj.phone2.select();
		obj.phone2.focus();
		return false;
	}
	if(obj.phone2.value.length!=3)
	{
		alert("Please enter a valid 10 digit phone number for billing!");
		obj.phone2.focus();
		return false;
	}
	if ((obj.phone3.value==null)||(obj.phone3.value=="")){
		alert("Please enter a valid 10 digit phone number for billing!")
		obj.phone3.focus();
		return false;
	}
	if (checkInternationalPhone(obj.phone3.value)==false){
		alert("Please enter a valid 10 digit phone number for billing")
		obj.phone3.select();
		obj.phone3.focus();
		return false;
	}
	if(obj.phone3.value.length!=4)
	{
		alert("Please enter a valid 10 digit phone number for billing");
		obj.phone3.focus();
		return false;
	}
	if(obj.phonetype.value=="0")
	{
		alert("Billing phone type can not be left blank!");
		obj.phonetype.focus();
		return false;
	}
	if ( (obj.aphone1.value!="") && (checkInternationalPhone(obj.aphone1.value)==false) ){
		alert("Please enter a valid 10 digit secondary phone number for billing!")
		obj.aphone1.select();
		obj.aphone1.focus();
		return false;
	}
	if(obj.aphone1.value!="" && obj.aphone1.value.length!=3)
	{
		alert("Please enter a valid 10 digit secondary phone number for billing!");
		obj.aphone1.focus();
		return false;
	}
	if ( (obj.aphone2.value!="") && (checkInternationalPhone(obj.aphone2.value)==false) ){
		alert("Please enter a valid 10 digit secondary phone number for billing!")
		obj.aphone2.select();
		obj.aphone2.focus();
		return false;
	}
	if(obj.aphone2.value!="" && obj.aphone2.value.length!=3)
	{
		alert("Please enter a valid 10 digit secondary phone number for billing!");
		obj.aphone2.focus();
		return false;
	}
	if ( (obj.aphone3.value!="") && (checkInternationalPhone(obj.aphone3.value)==false) ){
		alert("Please enter a valid 10 digit secondary phone number for billing!")
		obj.aphone3.select();
		obj.aphone3.focus();
		return false;
	}
	if(obj.aphone3.value!="" && obj.aphone3.value.length!=4)
	{
		alert("Please enter a valid 10 digit secondary phone number for billing!");
		obj.aphone3.focus();
		return false;
	}
	if( (obj.aphone1.value!="" || obj.aphone2.value!="" || obj.aphone3.value!="")  && (obj.aphonetype.value=="0") )
	{
		alert("Please enter secondary phone type for billing!");
		obj.aphonetype.focus();
		return false;
	}
	
	/********** credit card information*****************/
	if(parseInt(obj.hacctype.value)!=1){
		if(obj.namecard.value=="")
		{
			alert("Name on card can not be left blank!");
			obj.namecard.focus();
			return false;
		}
		if(obj.cardno.value=="")
		{
			alert("Card number can not be left blank!");
			obj.cardno.focus();
			return false;
		}
		if(obj.cardtype.value=="")
		{
			alert("Card type can not be left blank!");
			obj.cardtype.focus();
			return false;
		}
		if(obj.cid.value=="")
		{
			alert("Cid can not be left blank!");
			obj.cid.focus();
			return false;
		}
	}
	if(obj.hponumber.value=="1" && obj.ponumber.value=="")
	{
		alert("Ponumber can not be left blank!");
		obj.ponumber.focus();
		return false;
	}
	/************end credit card information***************/
	
	/*sipping address validation*/
	if(obj.sname.value=="")
	{
		alert("Ship-to address name can not be left blank!");
		obj.sname.focus();
		return false;
	}
	if(obj.scountry.value=='0')
	{
		alert("Ship-to address country can not be left blank!");
		obj.scountry.focus();
		return false;
	}
	if(obj.sstreet1.value=="")
	{
		alert("Ship-to address street can not be left blank!");
		obj.sstreet1.focus();
		return false;
	}
	if(obj.scity.value=="")
	{
		alert("Ship-to address city can not be left blank!");
		obj.scity.focus();
		return false;
	}
	if(obj.sstate.value=='0')
	{
		alert("Ship-to address state can not be left blank!");
		obj.sstate.focus();
		return false;
	}
	if(obj.szip.value=="")
	{
		alert("Ship-to address zip can not be left blank!");
		obj.szip.focus();
		return false;
	}
	if(obj.szip.value.length!=5)
	{
		alert("Please fill ship-to address zip code with 5 characters!");
		obj.szip.focus();
		return false;
	}
	for(i=0; i<5; i++)
   	{
		if (digits.indexOf(obj.szip.value.charAt(i))<0)
    	{	
		 alert("Please enter numeric value for ship-to address")
    	 obj.szip.focus();
		 obj.szip.select();
		 return false;
		}
		
     }
	if( (obj.szip2.value!="") && (obj.szip2.value.length!=4) )
	{
		alert("Fill ship-to address Zip+4 with 4 characters or leave it blank!");
		obj.szip2.focus();
		return false;
	}
	for(i=0; i<4; i++)
   	{
		if (digits.indexOf(obj.szip2.value.charAt(i))<0)
    	{	
		 alert("Please enter numeric value for ship-to address Zip+4")
    	 obj.szip2.focus();
		 obj.szip2.select();
		 return false;
		}
		
     }
	 if ((obj.sphone1.value==null)||(obj.sphone1.value=="")){
		alert("Please enter a valid 10 digit phone number for ship-to address!")
		obj.sphone1.focus();
		return false;
	}
	if (checkInternationalPhone(obj.sphone1.value)==false){
		alert("Please enter a valid 10 digit phone number for ship-to address!")
		obj.sphone1.select();
		obj.sphone1.focus();
		return false;
	}
	if(obj.sphone1.value.length!=3)
	{
		alert("Please enter a valid 10 digit  phone number for ship-to address!");
		obj.sphone1.focus();
		return false;
	}
	if ((obj.sphone2.value==null)||(obj.sphone2.value=="")){
		alert("Please enter a valid 10 digit phone number for ship-to address!")
		obj.sphone2.focus();
		return false;
	}
	if (checkInternationalPhone(obj.sphone2.value)==false){
		alert("Please enter a valid 10 digit phone number for ship-to address!")
		obj.sphone2.select();
		obj.sphone2.focus();
		return false;
	}
	if(obj.sphone2.value.length!=3)
	{
		alert("Please enter a valid 10 digit  phone number for ship-to address!");
		obj.sphone2.focus();
		return false;
	}
	if ((obj.sphone3.value==null)||(obj.sphone3.value=="")){
		alert("Please enter a valid 10 digit  phone number for ship-to address!")
		obj.sphone3.focus();
		return false;
	}
	if (checkInternationalPhone(obj.sphone3.value)==false){
		alert("Please enter a valid 10 digit  phone number for ship-to address!")
		obj.sphone3.select();
		obj.sphone3.focus();
		return false;
	}
	if(obj.sphone3.value.length!=4)
	{
		alert("Please enter a valid 10 digit phone number for ship-to address!");
		obj.sphone3.focus();
		return false;
	}
	if( (obj.sphone1.value!="" || obj.sphone2.value!="" || obj.sphone3.value!="" ) && (obj.sphonetype.value=="0") )
	{
		alert("Ship-to address phone type can not be left blank!");
		obj.sphonetype.focus();
		return false;
	}
	
	if ( (obj.saphone1.value!="") && (checkInternationalPhone(obj.saphone1.value)==false) ){
		alert("Please enter a valid 10 digit secondary phone number for ship-to address!")
		obj.saphone1.select();
		obj.saphone1.focus();
		return false;
	}
	if(obj.saphone1.value!="" && obj.saphone1.value.length!=3)
	{
		alert("Please enter a valid 10 digit secondary phone number for ship-to address!");
		obj.saphone1.focus();
		return false;
	}
	
	if ( (obj.saphone2.value!="") && (checkInternationalPhone(obj.saphone2.value)==false) ){
		alert("Please enter a valid 10 digit  secondary phone number for ship-to address!")
		obj.saphone2.select();
		obj.saphone2.focus();
		return false;
	}
	if(obj.saphone2.value!="" && obj.saphone2.value.length!=3)
	{
		alert("Please enter a valid 10 digit secondary phone number for ship-to address!");
		obj.saphone2.focus();
		return false;
	}
	if ( (obj.saphone3.value!="") && (checkInternationalPhone(obj.saphone3.value)==false) ){
		alert("Please enter a valid 10 digit  secondary phone number for ship-to address!")
		obj.saphone3.select();
		obj.saphone3.focus();
		return false;
	}
	if(obj.saphone3.value!="" && obj.saphone3.value.length!=4)
	{
		alert("Please enter a valid 10 digit secondary phone number for ship-to address!");
		obj.saphone3.focus();
		return false;
	}
	if( (obj.saphone1.value!="" || obj.saphone2.value!="" || obj.saphone3.value!="" ) && (obj.saphonetype.value=="0") )
	{
		alert("Ship-to address secondary phone type can not be left blank!");
		obj.saphonetype.focus();
		return false;
	}
	if(parseInt(obj.hacctype.value)==0)
	{
		if(obj.crditinfo.checked==false)
		{
			alert("Please check to create an account!");
			obj.crditinfo.focus();
			return false;
		}
	}
		

	if(obj.loginid.value=="")
	{
		alert("Login id can not be left blank!");
		obj.loginid.focus();
		return false;
	}
	/*if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj.loginmail.value)))
	{
		alert("Invalid E-mail Address! Please re-enter!")
		obj.loginmail.focus();
		obj.loginmail.select();
		return false;
	}*/
	if(obj.pwd.value=="")
	{
		alert("Password can not be left blank!");
		obj.pwd.focus();
		return false;
	}
	if(obj.pwd2.value=="")
	{
		alert("Verify password can not be left blank!");
		obj.pwd2.focus();
		return false;
	}
	if(obj.secq.value=="")
	{
		alert("Secret question can not be left blank!");
		obj.secq.focus();
		return false;
	}
	if(obj.seca.value=="")
	{
		alert("Answer field can not be left blank!");
		obj.seca.focus();
		return false;
	}
	if(obj.type.value=="3" && obj.taxid.value=="")
	{
		alert("TaxId can not be left blank!");
		obj.taxid.focus();
		return false;
	}
	
	/* end*/
	
}

<!--creadition card information validation-->
function cidInfoValid()
{
	var obj=document.cidForm;
	if(obj.amount.value=="")
	{
		alert("Please enter your amount!");
		obj.amount.focus();
		return false;
	}
	if(obj.amount.value!=parseFloat(obj.amount.value))
	{
		alert("Please enter a valid amount!");
		obj.amount.focus();
		obj.amount.select();
		return false;
	}
	if(obj.name.value=="")
	{
		alert("Please enter your name on credit card!");
		obj.name.focus();
		return false;
	}
	if(obj.cc_num.value=="")
	{
		alert("Please enter your credit card number!");
		obj.cc_num.focus();
		return false;
	}
	if(obj.cc_cid.value=="")
	{
		alert("Please enter your CCV/CVV code!");
		obj.cc_cid.focus();
		return false;
	}
	if(obj.cc_exp.value=="")
	{
		alert("Please enter your expiration date of credit card!");
		obj.cc_exp.focus();
		return false;
	}	
	if(obj.fname.value=="")
	{
		alert("Please enter your name!");
		obj.fname.focus();
		return false;
	}	
	if(obj.company.value=="")
	{
		alert("Please enter your company name!");
		obj.company.focus();
		return false;
	}
	if(obj.cc_addr.value=="")
	{
		alert("Please enter your address!");
		obj.cc_addr.focus();
		return false;
	}
	if(obj.cc_city.value=="")
	{
		alert("Please enter your city!");
		obj.cc_city.focus();
		return false;
	}
	if(obj.cc_state.value=="")
	{
		alert("Please enter your state!");
		obj.cc_state.focus();
		return false;
	}	
	if(obj.cc_zip.value=="")
	{
		alert("Please enter your zip code!");
		obj.cc_zip.focus();
		return false;
	}	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj.email.value)))
	{
		alert("Invalid Email Address! Please re-enter!")
		obj.email.focus();
		obj.email.select();
		return false;
	}
}
<!-- end credit card information-->







function onPageValidation(field)
{

	var obj=document.form1;
	digits="0123456789" //degits
	
	if(field=='email')
	{
		
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj.email.value)))
		{
			alert("Invalid Email Address! Please re-enter!")
			obj.email.focus();
			obj.email.select();
			return false;
		}
	}
	if(field=='name')
	{
		if(obj.name.value=="")
		{
			alert("Billing name can not be left blank!");
			obj.name.focus();
			return false;
		}
		if(parseInt(obj.hacctype.value)!=1)
		{		   
			if(obj.company.value=="")
			{
				alert("Billing company can not be left blank!");
				obj.company.focus();
				return false;
			}
		}
	}
	if(field=='company')
	{
		if(parseInt(obj.hacctype.value)!=1)
		{		   
			if(obj.company.value=="")
			{
				alert("Billing company can not be left blank!");
				obj.company.focus();
				return false;
			}
		}
	}
	if(field=='country')
	{
		if(obj.country.value=="0")
		{
		alert("Billing country can not be left blank!");
		obj.country.focus();
		return false;
		}
	}
	if(field=='street1')
	{
		if(obj.street1.value=="")
		{
		alert("Billing street can not be left blank!");
		obj.street1.focus();
		return false;
		}	
	}
	if(field=='city')
	{
		if(obj.city.value=="")
		{
		alert("Billing city can not be left blank!");
		obj.city.focus();
		return false;
		}
	}
	if(field=='state')
	{
		if(obj.state.value=="0")
		{
		alert("Billing state can not be left blank!");
		obj.state.focus();
		return false;
		}
	}
	if(field=='zip')
	{
		if(obj.zip.value=="")
		{
		alert("Billing zip code can not be left blank!");
		obj.zip.focus();
		return false;
		}
		if(obj.zip.value.length!=5)
		{
		alert("Please fill billing zip code with 5 characters!");
		obj.zip.focus();
		return false;
		}
		for(i=0; i<5; i++)
		{
			if (digits.indexOf(obj.zip.value.charAt(i))<0)
			{	
			 alert("Please enter numeric value for billing zip code!")
			 obj.zip.focus();
			 obj.zip.select();
			 return false;
			}
		
		}
	}
	if(field=='zip2')
	{
		if( (obj.szip2.value!="") && (obj.szip2.value.length!=4) )
		{
			alert("Fill ship-to address Zip+4 with 4 characters or leave it blank!");
			obj.szip2.focus();
			return false;
		}
		for(i=0; i<4; i++)
		{
			if (digits.indexOf(obj.szip2.value.charAt(i))<0)
			{	
			 alert("Please enter numeric value for ship-to address Zip+4")
			 obj.szip2.focus();
			 obj.szip2.select();
			 return false;
			}
			
		}
	}
	
	if(field=='phone1')
	{
		if ((obj.phone1.value==null)||(obj.phone1.value=="")){
			alert("Please enter a valid 10 digit phone number for billing!")
			obj.phone1.focus();
			return false;
		}
		if (checkInternationalPhone(obj.phone1.value)==false){
			alert("Please enter a valid 10 digit phone number for billing!")
			obj.phone1.select();
			obj.phone1.focus();
			return false;
		}
		if(obj.phone1.value.length!=3)
		{
			alert("Please enter a valid 10 digit phone number for billing!");
			obj.phone1.focus();
			return false;
		}
	}
	if(field=='phone2')
	{
		if ((obj.phone2.value==null)||(obj.phone2.value=="")){
		alert("Please enter a valid 10 digit phone number for billing!")
		obj.phone2.focus();
		return false;
		}
		if (checkInternationalPhone(obj.phone2.value)==false){
			alert("Please enter a valid 10 digit phone number for billing!")
			obj.phone2.select();
			obj.phone2.focus();
			return false;
		}
		if(obj.phone2.value.length!=3)
		{
			alert("Please enter a valid 10 digit phone number for billing!");
			obj.phone2.focus();
			return false;
		}
	}
	if(field=='phone3')
	{
		if ((obj.phone3.value==null)||(obj.phone3.value=="")){
		alert("Please enter a valid 10 digit phone number for billing!")
		obj.phone3.focus();
		return false;
		}
		if (checkInternationalPhone(obj.phone3.value)==false){
			alert("Please enter a valid 10 digit phone number for billing")
			obj.phone3.select();
			obj.phone3.focus();
			return false;
		}
		if(obj.phone3.value.length!=4)
		{
			alert("Please enter a valid 10 digit phone number for billing");
			obj.phone3.focus();
			return false;
		}
	}
	if(field=='aphone1')
	{
		if ((obj.aphone1.value==null)||(obj.aphone1.value=="")){
			alert("Please enter a valid 10 digit phone number for billing!")
			obj.aphone1.focus();
			return false;
		}
		if (checkInternationalPhone(obj.aphone1.value)==false){
			alert("Please enter a valid 10 digit phone number for billing!")
			obj.aphone1.select();
			obj.aphone1.focus();
			return false;
		}
		if(obj.aphone1.value.length!=3)
		{
			alert("Please enter a valid 10 digit phone number for billing!");
			obj.aphone1.focus();
			return false;
		}
	}
	if(field=='aphone2')
	{
		if ((obj.aphone2.value==null)||(obj.aphone2.value=="")){
		alert("Please enter a valid 10 digit phone number for billing!")
		obj.aphone2.focus();
		return false;
		}
		if (checkInternationalPhone(obj.aphone2.value)==false){
			alert("Please enter a valid 10 digit phone number for billing!")
			obj.aphone2.select();
			obj.aphone2.focus();
			return false;
		}
		if(obj.aphone2.value.length!=3)
		{
			alert("Please enter a valid 10 digit phone number for billing!");
			obj.aphone2.focus();
			return false;
		}
	}
	if(field=='aphone3')
	{
		if ((obj.aphone3.value==null)||(obj.aphone3.value=="")){
		alert("Please enter a valid 10 digit phone number for billing!")
		obj.aphone3.focus();
		return false;
		}
		if (checkInternationalPhone(obj.aphone3.value)==false){
			alert("Please enter a valid 10 digit phone number for billing")
			obj.aphone3.select();
			obj.aphone3.focus();
			return false;
		}
		if(obj.aphone3.value.length!=4)
		{
			alert("Please enter a valid 10 digit phone number for billing");
			obj.aphone3.focus();
			return false;
		}
	}
	if(field=='phonetype')
	{
		if(obj.phonetype.value=="0")
		{
		alert("Billing phone type can not be left blank!");
		obj.phonetype.focus();
		return false;
		}
	}
	if(field=='aphonetype')
	{
		if(obj.phonetype.value=="0")
		{
		alert("Billing phone type can not be left blank!");
		obj.phonetype.focus();
		return false;
		}
	}
	/*if(field=='aphone1')
	{
		if ( (obj.aphone1.value!="") && (checkInternationalPhone(obj.aphone1.value)==false) ){
		alert("Please enter a valid 10 digit secondary phone number for billing!")
		obj.aphone1.select();
		obj.aphone1.focus();
		return false;
		}
		if(obj.aphone1.value!="" && obj.aphone1.value.length!=3)
		{
			alert("Please enter a valid 10 digit secondary phone number for billing!");
			obj.aphone1.focus();
			return false;
		}
	}
	if(field=='aphone2')
	{
		if ( (obj.aphone2.value!="") && (checkInternationalPhone(obj.aphone2.value)==false) ){
		alert("Please enter a valid 10 digit secondary phone number for billing!")
		obj.aphone2.select();
		obj.aphone2.focus();
		return false;
		}
		if(obj.aphone2.value!="" && obj.aphone2.value.length!=3)
		{
			alert("Please enter a valid 10 digit secondary phone number for billing!");
			obj.aphone2.focus();
			return false;
		}
	}
	if(field=='aphone3')
	{
		if ( (obj.aphone3.value!="") && (checkInternationalPhone(obj.aphone3.value)==false) ){
		alert("Please enter a valid 10 digit secondary phone number for billing!")
		obj.aphone3.select();
		obj.aphone3.focus();
		return false;
		}
		if(obj.aphone3.value!="" && obj.aphone3.value.length!=4)
		{
			alert("Please enter a valid 10 digit secondary phone number for billing!");
			obj.aphone3.focus();
			return false;
		}
	}
	if(field=='aphonetype')
	{
		if( (obj.aphone1.value!="" || obj.aphone2.value!="" || obj.aphone3.value!="")  && (obj.aphonetype.value=="0") )
		{
		alert("Please enter secondary phone type for billing!");
		obj.aphonetype.focus();
		return false;
		}	
	}*/
	/********** credit card information*****************/
	if(field=='namecard')
	{
		if(parseInt(obj.hacctype.value)!=1){
			if(obj.namecard.value=="")
			{
				alert("Name on card can not be left blank!");
				obj.namecard.focus();
				return false;
			}
		}
	}
	if(field=='cardno')
	{
		if(obj.cardno.value=="")
		{
			alert("Card number can not be left blank!");
			obj.cardno.focus();
			return false;
		}
	}
	if(field=='cardtype')
	{
		if(obj.cardtype.value=="")
		{
			alert("Card type can not be left blank!");
			obj.cardtype.focus();
			return false;
		}
	}
	if(field=='cid')
	{
		if(obj.cid.value=="")
		{
			alert("Cid can not be left blank!");
			obj.cid.focus();
			return false;
		}
	}
	if(field=='ponumber')
	{
		if(obj.hponumber.value=="1" && obj.ponumber.value=="")
		{
			alert("Ponumber can not be left blank!");
			obj.ponumber.focus();
			return false;
		}
	}
	if(field=='sname')
	{
		if(obj.sname.value=="")
		{
		alert("Ship-to address name can not be left blank!");
		obj.sname.focus();
		return false;
		}
	}
	if(field=='scountry')
	{
		if(obj.scountry.value=='0')
		{
		alert("Ship-to address country can not be left blank!");
		obj.scountry.focus();
		return false;
		}
	}
	if(field=='sstreet1')
	{
		if(obj.sstreet1.value=="")
		{
		alert("Ship-to address street can not be left blank!");
		obj.sstreet1.focus();
		return false;
		}
	}
	if(field=='scity')
	{
		if(obj.scity.value=="")
		{
		alert("Ship-to address city can not be left blank!");
		obj.scity.focus();
		return false;
		}
	}
	if(field=='sstate')
	{
		if(obj.sstate.value=='0')
		{
			alert("Ship-to address state can not be left blank!");
			obj.sstate.focus();
			return false;
		}
	}
	/*sipping address validation*/
	if(field=='szip')
	{
		if(obj.szip.value=="")
		{
		alert("Ship-to address zip can not be left blank!");
		obj.szip.focus();
		return false;
		}
		if(obj.szip.value.length!=5)
		{
			alert("Please fill ship-to address zip code with 5 characters!");
			obj.szip.focus();
			return false;
		}
		for(i=0; i<5; i++)
		{
			if (digits.indexOf(obj.szip.value.charAt(i))<0)
			{	
			 alert("Please enter numeric value for ship-to address")
			 obj.szip.focus();
			 obj.szip.select();
			 return false;
			}
			
		 }
	}
	if(field=='szip2')
	{
		if( (obj.szip2.value!="") && (obj.szip2.value.length!=4) )
		{
			alert("Fill ship-to address Zip+4 with 4 characters or leave it blank!");
			obj.szip2.focus();
			return false;
		}
		for(i=0; i<4; i++)
		{
			if (digits.indexOf(obj.szip2.value.charAt(i))<0)
			{	
			 alert("Please enter numeric value for ship-to address Zip+4")
			 obj.szip2.focus();
			 obj.szip2.select();
			 return false;
			}
			
		 }
	}
	if(field=='sphone1')
	{
		if ((obj.sphone1.value==null)||(obj.sphone1.value=="")){
		alert("Please enter a valid 10 digit phone number for ship-to address!")
		obj.sphone1.focus();
		return false;
		}
		if (checkInternationalPhone(obj.sphone1.value)==false){
			alert("Please enter a valid 10 digit phone number for ship-to address!")
			obj.sphone1.select();
			obj.sphone1.focus();
			return false;
		}
		if(obj.sphone1.value.length!=3)
		{
			alert("Please enter a valid 10 digit  phone number for ship-to address!");
			obj.sphone1.focus();
			return false;
		}
	}
	if(field=='sphone2')
	{
		if ((obj.sphone2.value==null)||(obj.sphone2.value=="")){
		alert("Please enter a valid 10 digit phone number for ship-to address!")
		obj.sphone2.focus();
		return false;
		}
		if (checkInternationalPhone(obj.sphone2.value)==false){
			alert("Please enter a valid 10 digit phone number for ship-to address!")
			obj.sphone2.select();
			obj.sphone2.focus();
			return false;
		}
		if(obj.sphone2.value.length!=3)
		{
			alert("Please enter a valid 10 digit  phone number for ship-to address!");
			obj.sphone2.focus();
			return false;
		}
	}
	if(field=='sphone3')
	{
		if ((obj.sphone3.value==null)||(obj.sphone3.value=="")){
		alert("Please enter a valid 10 digit  phone number for ship-to address!")
		obj.sphone3.focus();
		return false;
		}
		if (checkInternationalPhone(obj.sphone3.value)==false){
			alert("Please enter a valid 10 digit  phone number for ship-to address!")
			obj.sphone3.select();
			obj.sphone3.focus();
			return false;
		}
		if(obj.sphone3.value.length!=4)
		{
			alert("Please enter a valid 10 digit phone number for ship-to address!");
			obj.sphone3.focus();
			return false;
		}	
	}
	if(field=='sphonetype')
	{
		if( (obj.sphone1.value!="" || obj.sphone2.value!="" || obj.sphone3.value!="" ) && (obj.sphonetype.value=="0") )
		{
			alert("Ship-to address phone type can not be left blank!");
			obj.sphonetype.focus();
			return false;
		}
	}
	if(field=='saphone1')
	{
		if ( (obj.saphone1.value!="") && (checkInternationalPhone(obj.saphone1.value)==false) ){
		alert("Please enter a valid 10 digit secondary phone number for ship-to address!")
		obj.saphone1.select();
		obj.saphone1.focus();
		return false;
		}
		if(obj.saphone1.value!="" && obj.saphone1.value.length!=3)
		{
			alert("Please enter a valid 10 digit secondary phone number for ship-to address!");
			obj.saphone1.focus();
			return false;
		}
	}
	if(field=='saphone2')
	{
		if ( (obj.saphone2.value!="") && (checkInternationalPhone(obj.saphone2.value)==false) ){
		alert("Please enter a valid 10 digit  secondary phone number for ship-to address!")
		obj.saphone2.select();
		obj.saphone2.focus();
		return false;
		}
		if(obj.saphone2.value!="" && obj.saphone2.value.length!=3)
		{
			alert("Please enter a valid 10 digit secondary phone number for ship-to address!");
			obj.saphone2.focus();
			return false;
		}
	}
	if(field=='saphone3')
	{
		if ( (obj.saphone3.value!="") && (checkInternationalPhone(obj.saphone3.value)==false) ){
		alert("Please enter a valid 10 digit  secondary phone number for ship-to address!")
		obj.saphone3.select();
		obj.saphone3.focus();
		return false;
		}
		if(obj.saphone3.value!="" && obj.saphone3.value.length!=4)
		{
			alert("Please enter a valid 10 digit secondary phone number for ship-to address!");
			obj.saphone3.focus();
			return false;
		}
	}
	if(field=='saphonetype')
	{
		if( (obj.saphone1.value!="" || obj.saphone2.value!="" || obj.saphone3.value!="" ) && (obj.saphonetype.value=="0") )
		{
			alert("Ship-to address secondary phone type can not be left blank!");
			obj.saphonetype.focus();
			return false;
		}
	}
	if(field=='hacctype')
	{
		if(parseInt(obj.hacctype.value)==0)
		{
			if(obj.crditinfo.checked==false)
			{
				alert("Please check to create an account!");
				obj.crditinfo.focus();
				return false;
			}
		}
	}
	if(field=='loginid')
	{
		if(obj.loginid.value=="")
		{
			alert("Login id can not be left blank!");
			obj.loginid.focus();
			return false;
		}
	}
	if(field=='pwd')
	{
		if(obj.pwd.value=="")
		{
			alert("Password can not be left blank!");
			obj.pwd.focus();
			return false;
		}
	}
	if(field=='pwd2')
	{
		if(obj.pwd2.value=="")
		{
			alert("Verify password can not be left blank!");
			obj.pwd2.focus();
			return false;
		}
	}
	if(field=='secq')
	{
		if(obj.secq.value=="")
		{
			alert("Secret question can not be left blank!");
			obj.secq.focus();
			return false;
		}
	}
	if(field=='seca')
	{
		if(obj.seca.value=="")
		{
			alert("Answer field can not be left blank!");
			obj.seca.focus();
			return false;
		}
	}
	if(field=='taxid')
	{
		if(obj.type.value=="3" && obj.taxid.value=="")
		{
			alert("TaxId can not be left blank!");
			obj.taxid.focus();
			return false;
		}
	}
	/************end credit card information***************/
}
<!--on check validation-->

<!--end-->

