Hi

have these checkout page where have billing address fields and credit card fields
there are two different scripts to check both billing address and credit card fields
but the functions just dont work when try to call them up with one button

if I use two buttons both functions do their job but on one form I want have one button...

will appreciate if you help me with these!

Code:
<HTML>
<HEAD>
  <TITLE>
    CHECKOUT
  </TITLE>
  <STYLE>
  </STYLE>
<SCRIPT SRC="language-en.js"></SCRIPT>
<SCRIPT SRC="nopcart.js"> 
</SCRIPT>
<script type="text/javascript">

var ccErrorNo = 0;
var ccErrors = new Array ()


ccErrors [0] = "Unknown card type";
ccErrors [1] = "No card number provided";
ccErrors [2] = "Credit card number is in invalid format";
ccErrors [3] = "Credit card number is invalid";
ccErrors [4] = "Credit card number has an inappropriate number of digits";


function allcheck()
{
if (testCreditCard ()){
if (expiredate()){
alert(" Your order has been placed");
return true


}
}

return false
}

function testCreditCard () {
  myCardNo = document.getElementById('CardNumber').value;
  myCardType = document.getElementById('CardType').value;
  if (checkCreditCard (myCardNo,myCardType)) {
   return true
  } 
  else {alert (ccErrors[ccErrorNo])};
  return false
}


function checkCreditCard (cardnumber, cardname) {
     
  // Array to hold the permitted card characteristics
  var cards = new Array();

  cards [0] = {name: "Visa", 
               length: "13,16", 
               prefixes: "4",
               checkdigit: true};
  cards [1] = {name: "MasterCard", 
               length: "16", 
               prefixes: "51,52,53,54,55",
               checkdigit: true};
  cards [2] = {name: "VisaElectron", 
               length: "16", 
               prefixes: "4026,417500,4508,4844,4913,4917",
               checkdigit: true};
  cards [3] = {name: "LaserCard", 
               length: "16,17,18,19", 
               prefixes: "6304,6706,6771,6709",
               checkdigit: true};
               
  // Establish card type
  var cardType = -1;
  for (var i=0; i<cards.length; i++) {


    // See if it is this card (ignoring the case of the string)
    if (cardname.toLowerCase () == cards[i].name.toLowerCase()) {
      cardType = i;
      break;
    }
  }
  
  // If card type not found, report an error
  if (cardType == -1) {
     ccErrorNo = 0;
     return false; 
  }
   
  // Ensure that the user has provided a credit card number
  if (cardnumber.length == 0)  {
     ccErrorNo = 1;
     return false; 
  }
    
  // Now remove any spaces from the credit card number
  cardnumber = cardnumber.replace (/\s/g, "");
  
  // Check that the number is numeric
  var cardNo = cardnumber
  var cardexp = /^[0-9]{13,19}$/;
  if (!cardexp.exec(cardNo))  {
     ccErrorNo = 2;
     return false; 
  }
       
  // Now check the modulus 10 check digit - if required
  if (cards[cardType].checkdigit) {
    var checksum = 0;                                  // running checksum total
    var mychar = "";                                   // next char to process
    var j = 1;                                         // takes value of 1 or 2
  
    // Process each digit one by one starting at the right
    var calc;
    for (i = cardNo.length - 1; i >= 0; i--) {
    
      // Extract the next digit and multiply by 1 or 2 on alternative digits.
      calc = Number(cardNo.charAt(i)) * j;
    
      // If the result is in two digits add 1 to the checksum total
      if (calc > 9) {
        checksum = checksum + 1;
        calc = calc - 10;
      }
    
      // Add the units element to the checksum total
      checksum = checksum + calc;
    
      // Switch the value of j
      if (j ==1) {j = 2} else {j = 1};
    } 
  
    // All done - if checksum is divisible by 10, it is a valid modulus 10.
    // If not, report an error.
    if (checksum % 10 != 0)  {
     ccErrorNo = 3;
     return false; 
    }
  }  
  
  // Check it's not a spam number
  if (cardNo == '5490997771092064') { 
    ccErrorNo = 5;
    return false; 
  }


  // The following are the card-specific checks we undertake.
  var LengthValid = false;
  var PrefixValid = false; 
  var undefined; 


  // We use these for holding the valid lengths and prefixes of a card type
  var prefix = new Array ();
  var lengths = new Array ();
    
  // Load an array with the valid prefixes for this card
  prefix = cards[cardType].prefixes.split(",");
      
  // Now see if any of them match what we have in the card number
  for (i=0; i<prefix.length; i++) {
    var exp = new RegExp ("^" + prefix[i]);
    if (exp.test (cardNo)) PrefixValid = true;
  }
      
  // If it isn't a valid prefix there's no point at looking at the length
  if (!PrefixValid) {
     ccErrorNo = 3;
     return false; 
  }
    
  // See if the length is valid for this card
  lengths = cards[cardType].length.split(",");
  for (j=0; j<lengths.length; j++) {
    if (cardNo.length == lengths[j]) LengthValid = true;
  }
  
  // See if all is OK by seeing if the length was valid. We only check the length if all else was 
  // hunky dory.
  if (!LengthValid) {
     ccErrorNo = 4;
     return false; 
  };   
  
  // The credit card is in the required format.
  return true;
}




function expiredate()
{
CC_EXPMO = document.getElementById("ExpiresM").value;
CC_EXPYR = document.getElementById("ExpiresY").value;


var d=new Date() 
if(CC_EXPMO<(d.getMonth()+1) && CC_EXPYR==(d.getFullYear()))
{
  alert("Card Expired")
   return false;
   }
   else{
   return true
   }
}






function CheckForm( theform )
{
	var bMissingFields = false;
	var strFields = "";
	
	if( theform.b_first.value == '' ){
		bMissingFields = true;
		strFields += "     Billing: First Name\n";
	}
	if( theform.b_last.value == '' ){
		bMissingFields = true;
		strFields += "     Billing: Last Name\n";
	}
	if( theform.b_addr.value == '' ){
		bMissingFields = true;
		strFields += "     Billing: Address\n";
	}
	if( theform.b_city.value == '' ){
		bMissingFields = true;
		strFields += "     Billing: City\n";
	}
	if( theform.b_state.value == '' ){
		bMissingFields = true;
		strFields += "     Billing: State\n";
	}
	if( theform.b_zip.value == '' ){
		bMissingFields = true;
		strFields += "     Billing: Zipcode\n";
	}
	if( theform.b_phone.value == '' ){
		bMissingFields = true;
		strFields += "     Billing: Phone\n";
	}
	if( theform.b_email.value == '' ){
		bMissingFields = true;
		strFields += "     Billing: Email\n";
	}
		
	if( bMissingFields ) {
		alert( "I'm sorry, but you must provide the following field(s) before continuing:\n" + strFields );
		return false;
	}
	
	return true;
}

</script>
</HEAD>
<BODY BGCOLOR="White" TEXT="Black" text align="center" >
<h1>CHECKOUT</h1>

<blockquote>
<FONT CLASS="checkout">
<form action="/cgi-bin/checkout.pl" method="POST" onSubmit="return CheckForm(this)">
    <NOBR>
    <SCRIPT>
        CheckoutCart();
    </SCRIPT>
    </NOBR>
<br>

<p>
<hr width=55% align=left>
<b><font class="greetext">Billing Information:</font></b><P>

<TABLE class="blacktext">
<TR><TD>Name:    </TD><TD><input type="text" size="18" name="b_first"> <input type="text" size="16" name="b_last"></TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="b_addr"> </TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="b_addr2"></TD></TR>
<TR><TD>City:    </TD><TD><input type="text" size="21" name="b_city"> </TD></TR>
<TR><TD>Phone:   </TD><TD><input type="text" size="37" name="b_phone"></TD></TR>
<TR><TD>Email:   </TD><TD><input type="text" size="37" name="b_email"> </TD></TR>
</TABLE>
<p> 
   

<hr width=55% align=left>




<hr width=55% align=left>
<b><font class="greetext">Credit Card Information:</font></b><P>

<TABLE class="blacktext">
<TR><TD>Select your card:    </TD><TD><select tabindex="11" id="CardType" style="margin-left: 10px;" class="over">
  <option value="Choose card">choose card</option>
  <option value="MasterCard">MasterCard</option>
  <option value="Visa">Visa</option>
  <option value="VisaElectron">Visa Electron</option>
  <option value="LaserCard">Laser</option></TD></TR>
<TR><TD>Number: </TD><TD><input type="text" id="CardNumber" maxlength="24" size="24" style="margin-left: 10px;" class="over" placeholder="Enter Card Number"/> </TD></TR>
<TR><TD>Expiry Date: </TD><TD><select name=ExpiresM id="ExpiresM" class="over">
    <option value=01 selected>01
    <option value=02 >02
    <option value=03 >03
    <option value=04 >04
    <option value=05 >05
    <option value=06 >06
    <option value=07 >07
    <option value=08 >08
    <option value=09 >09
    <option value=10 >10
    <option value=11 >11
    <option value=12 >12
  </select></TD></TR>
<TR><TD>Expiry Year:    </TD><TD><select name=ExpiresY id="ExpiresY" class="over">  
    <option value=2012 selected >2012
    <option value=2013 >2013
    <option value=2014 >2014
    <option value=2015 >2015
    <option value=2016 >2016
    <option value=2017 >2017
    <option value=2018 >2018
    <option value=2019 >2019
    <option value=2020 >2020
    <option value=2021 >2021
  </select></TD></TR>
<TR><TD>Validation Code:   </TD><TD><input name="Id"class="over" TYPE="text" value="" size="8" placeholder="Enter CVV"> &nbsp;</TD></TR>
</TABLE>


<p>
<hr width=55% align=left>
<b><font color="#660000">THANK YOU </font></b><P>
<input type=submit Value="Submit Order" onclick="allcheck()"> <INPUT type=RESET value="  Clear Form  ">
    </p>
    </center>    
    </FORM>    
</blockquote>

</td></tr></table>

<hr width=55% align=left>


</BODY>
</html>