function isEmpty(strcnumber, strcsv, strfirst_name, strlast_name, stremail, strphone, strbilladdress, strbillcity, strbillzip, strshipaddress, strshipcity, strshipzip) {

var strcnumber = document.forms[0].cnumber.value ;
var strcsv = document.forms[0].csv.value ;
var strfirst_name = document.forms[0].first_name.value ;
var strlast_name = document.forms[0].last_name.value ;
var stremail = document.forms[0].email.value ;
var strphone = document.forms[0].phone.value ;
var strshipaddress = document.forms[0].shipaddress.value ;
var strshipcity = document.forms[0].shipcity.value ;
var strshipzip = document.forms[0].shipzip.value ;
var strbilladdress = document.forms[0].billaddress.value ;
var strbillcity = document.forms[0].billcity.value ;
var strbillzip = document.forms[0].billzip.value ;

	//credit card number field 
    if (strcnumber == "" || strcnumber == null || strcnumber.charAt(0) == ' ')
    {
    alert("\"Credit Card #\" is a mandatory field.\nPlease amend and retry.")
    return false;
    }
    return true;
	
  //csv field 
    if (strcsv == "" || strcsv == null || strcsv.charAt(0) == ' ')
    {
    alert("\"CSV\" is a mandatory field.\nPlease amend and retry.")
    return false;
    }
    return true;
	
  //name field
    if (strfirst_name == "" || strfirst_name == null || !isNaN(strfirst_name) || strfirst_name.charAt(0) == ' ')
    {
    alert("\"First name\" is a mandatory field.\nPlease amend and retry.")
    return false;
    }
	
  //last name field
    if (strlast_name == "" || strlast_name == null || !isNaN(strlast_name) || strlast_name.charAt(0) == ' ')
    {
    alert("\"Last name\" is a mandatory field.\nPlease amend and retry.")
    return false;
    }

  //email field 
    if (stremail == "" || stremail == null || stremail.charAt(0) == ' ')
    {
    alert("\"Email\" is a mandatory field.\nPlease amend and retry.")
    return false;
    }

  //phone field 
    if (strphone == "" || strphone == null || strphone.charAt(0) == ' ')
    {
    alert("\"Phone\" is a mandatory field.\nPlease amend and retry.")
    return false;
    }
    return true;
	
  //address field 
    if (strshipaddress == "" || strshipaddress == null || strshipaddress.charAt(0) == ' ')
    {
    alert("\"Shipping address\" is a mandatory field.\nPlease amend and retry.")
    return false;
    }
    return true;
	
  //city field 
    if (strshipcity == "" || strshipcity == null || strshipcity.charAt(0) == ' ')
    {
    alert("\"Shipping city\" is a mandatory field.\nPlease amend and retry.")
    return false;
    }
    return true;
	
  //zip field 
    if (strshipzip == "" || strshipzip == null || strshipzip.charAt(0) == ' ')
    {
    alert("\"Shipping zip code\" is a mandatory field.\nPlease amend and retry.")
    return false;
    }
    return true;
	
	//address field 
    if (strbilladdress == "" || strbilladdress == null || strbilladdress.charAt(0) == ' ')
    {
    alert("\"Billing address\" is a mandatory field.\nPlease amend and retry.")
    return false;
    }
    return true;
	
  //city field 
    if (strbillcity == "" || strbillcity == null || strbillcity.charAt(0) == ' ')
    {
    alert("\"Billing city\" is a mandatory field.\nPlease amend and retry.")
    return false;
    }
    return true;
	
  //zip field 
    if (strbillzip == "" || strbillzip == null || strbillzip.charAt(0) == ' ')
    {
    alert("\"Billing zip code\" is a mandatory field.\nPlease amend and retry.")
    return false;
    }
    return true;
}


//function to check valid email address
function isValidEmail(stremail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  stremail = document.forms[0].email.value;

   // search email text for regular exp matches
    if (stremail.search(validRegExp) == -1) 
   {
      alert('A valid e-mail address is required.\nPlease amend and retry');
      return false;
    } 
    return true; 
}


//function that performs all functions, defined in the onsubmit event handler

function check(form){
if (isEmpty(form.cnumber)){
  if (isEmpty(form.expiration)){
	if (isEmpty(form.csv)){
    	if (isEmpty(form.first_name)){
			if (isEmpty(form.last_name)){
				if (isEmpty(form.phone)){
					if (isEmpty(form.email)){
						if (isEmpty(form.billaddress)){
							if (isEmpty(form.billcity)){
								if (isEmpty(form.billzip)){
									if (isEmpty(form.shipaddress)){
										if (isEmpty(form.shipcity)){
											if (isEmpty(form.shipzip)){
												if (isValidEmail(form.email)){
									 			 return true;
												}
											}
										} 
									}
								}
							}
						}
					}
				}
			}
	  	}
	 }
  }
}
return false;
}