?
Solved

Cleaning up Credit Card Validation

Posted on 2006-05-06
10
Medium Priority
?
297 Views
Last Modified: 2012-05-05
I have little experience with Javascripts. The page should have the following fields:
      Name
      Address
      City, State, Zip
      Telephone number
      Date of birth
      Radio buttons for credit card type
      Credit card number
      Credit card expiration date month
      Credit card expiration date year
      Add a selection list for the state.
      Add a selection list for the credit card expiration month.
      Add a selection list or text box for expiration year. (If you are using selection box, make sure that there are at least two years prior to the current year)
      Validate the credit card expiration date (month and year).
      Verify in a comparison with the current date that the credit card expiration date is valid.
      Add a mortgage calculator to the page as a value added aspect for the customer.
      Allow only numbers in the credit card field (use onChange or onKeyUp event handler to see what is being entered into the field)
      Allow only 15 digits for a Amex card selection and 16 digits for Visa and Mastercard
      Make sure that the first digit is “4” for a Visa card or “5” for a Mastercard or “3” for an Amex.  Use ‘switch’ statements to perform the task.

Here is my Javascript:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "http://www.w3.org/TR/html4/loose.dtd">
<!--
   Test
-->
</html>
</head>
      <title>Credit card Entry and Mortage Calculator</title>

      <script language="Javascript" type=”text/javascript”>
      <!-- HIDE FROM INCOMPATIBLE BROWSERS
      </script>

</form>
<h3 align= "center" font face="arial">Individual Address and Credit Card Form</h3>

</TABLE>            
<TABLE align = "center" border=20 cellspacing=0 cellpadding=2 bgcolor="#66FF33">
<tr valign=>
<TD>
      <font face="arial">First Name</font>
</TD>
<TD>
      <input type=text name="First Name" size=25,1 maxlength=25>
</TD></tr>
<tr>
<TD>
      <font face="arial">Last Name</font>
</TD>
<TD>
      <input type=text name="Last Name" size=25,1 maxlength=25>
</TD></tr>
<tr>
<TD>
      <font face="arial">Address</font>
</TD>
<TD>
      <input type=text name="Address" size=25,1 maxlength=25>
</TD></tr>
<tr>
<TD>
      <font face="arial">City</font>
</TD>
<TD>
      <input type=text name="City" size=25,1 maxlength=25>
</TD></tr>
<tr>
<TD>
      <font face="arial">State</font>
</TD>
<TD>
<select value="">
      <option value="" selected>Please Select</option>
      <option value="AK">Alaska</option>
      <option value="AL">Alabama</option>
      <option value="AR">Arkansas</option>
      <option value="AS">American Samoa</option>      
      <option value="AZ">Arizona</option>
      <option value="CA">California</option>
      <option value="CO">Colorada</option>
      <option value="CT">Conneticut</option>
      <option value="DC">District of Colombia</option>
      <option value="DE">Delaware</option>
      <option value="FL">Florida</option>
      <option value="FM">Federated States</option>
      <option value="GA">Georgia</option>
      <option value="GU">Guam</option>
      <option value="HI">Hawaii</option>
      <option value="IA">Iowa</option>
      <option value="ID">Idaho</option>
      <option value="IL">Illinois</option>
      <option value="IN">Indiana</option>
      <option value="KS">Kansas</option>
      <option value="KY">Kentucky</option>
      <option value="LA">Louisiana</option>
      <option value="MA">Massachusetts</option>
      <option value="MD">Maryland</option>
      <option value="ME">Maine</option>
      <option value="MI">Michigan</option>
      <option value="MN">Minnesota</option>
      <option value="MO">Missouri</option>
      <option value="MS">Mississippi</option>
      <option value="MT">Montana</option>
      <option value="NC">North Carolina</option>
      <option value="ND">North Dakota</option>
      <option value="NE">Nebraska</option>
      <option value="NH">New Hampshire</option>
      <option value="NJ">New Jersey</option>
      <option value="NM">New Mexico</option>
      <option value="NV">Nevada</option>
      <option value="NY">New York</option>
      <option value="OH">Ohio</option>
      <option value="OK">Oklahoma</option>
      <option value="OR">Oregon</option>
      <option value="PA">Pennsylvania</option>
      <option value="PR">Puerto Rico</option>
      <option value="RI">Rhode Island</option>
      <option value="SC">South Carolina</option>
      <option value="SD">South Dakota</option>
      <option value="TN">Tennessee</option>
      <option value="TX">Texas</option>
      <option value="UT">Utah</option>
      <option value="VI">Virgin Islands</option>
      <option value="VT">Vermont</option>
      <option value="VA">Virginia</option>
      <option value="WA">Washington</option>
      <option value="WI">Wisconsin</option>
      <option value="WV">West Virginia</option>
      <option value="WY">Wyoming</option>
</select>
</TD></tr>
<tr>
<TD>
      <font face="arial">Zip Code</font>
</TD>
<TD>
      <input type=text name="Zip" size=5,1 maxlength=5>
</TD></tr>
<TD>
      <font face="arial">Telephone (Area Code)</font>
</TD>
<TD>
      <input type=text name="Telephone" size=13,1 maxlength=13>
</TD></tr>
<TD>
      <font face="arial">Date of Birth</font>
</TD>
<TD>
<select value="">
      <option value="">Month</option>
      <option value="JAN">January</option>
      <option value="FEB">February</option>
      <option value="MA">March</option>
      <option value="APR">April</option>
      <option value="MAY">May</option>
      <option value="JUN">June</option>
      <option value="JUL">July</option>
      <option value="AUG">August</option>
      <option value="SEP">September</option>
      <option value="OCT">October</option>
      <option value="NOV">November</option>
      <option value="DEC">December</option>
</select>
&nbsp:
<select value="">
      <option value="">Day</option>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      <option value="6">6</option>
      <option value="7">7</option>
      <option value="8">8</option>
      <option value="9">9</option>
      <option value="10">10</option>
      <option value="11">11</option>
      <option value="12">12</option>
        <option value="13">13</option>
      <option value="14">14</option>
      <option value="15">15</option>
      <option value="16">16</option>
      <option value="17">17</option>
      <option value="18">18</option>
      <option value="19">19</option>
      <option value="20">20</option>
      <option value="21">21</option>
      <option value="22">22</option>
      <option value="23">23</option>
      <option value="24">24</option>
      <option value="25">25</option>
      <option value="26">26</option>
      <option value="27">27</option>
      <option value="28">28</option>
      <option value="29">29</option>
      <option value="30">30</option>
      <option value="31">31</option>
</select>
&nbsp:
<select value="">
      <option value="">Year</option>
      <option value="19">19</option>
      <option value="20">20</option>
</select>
&nbsp:
<select value="">
      <option value="">0</option>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      <option value="6">6</option>
        <option value="7">7</option>
      <option value="8">8</option>
      <option value="9">9</option>
</select>
&nbsp:
<select value="">
      <option value="">0</option>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
      <option value="6">6</option>
        <option value="7">7</option>
      <option value="8">8</option>
      <option value="9">9</option>
</select>
</TD></tr>
<TD>
      <font face="arial">Credit Card Number</font>
<TD>
      <input type=text name="Credit Card Number" size=16,1 maxlength=16>
&nbsp:
      <font face="arial">EIC</font>
&nbsp:
      <input type=text name="EIC" size=4,1 maxlength=4>
<TD><tr>
<TD>
      <font face="arial">Credit Card Company</font>
</TD>
<TD>
<select value="">
      <option value="">Credit Card</option>
      <option value="A">American Express</option>
      <option value="D">Diners Card</option>
      <option value="M">Master Card</option>
      <option value="Visa">Visa Card</option>
</select>
&nbsp:
      <font face="arial">Expiration</font>
<select value="">
      <option value="">Month</option>
      <option value="JAN">January</option>
      <option value="FEB">February</option>
      <option value="MA">March</option>
      <option value="APR">April</option>
      <option value="MAY">May</option>
      <option value="JUN">June</option>
      <option value="JUL">July</option>
      <option value="AUG">August</option>
      <option value="SEP">September</option>
      <option value="OCT">October</option>
      <option value="NOV">November</option>
      <option value="DEC">December</option>
</select>
&nbsp:
<select value="">
        <option value="">Year</option>
      <option value="6">2006</option>
      <option value="7">2007</option>
      <option value="8">2008</option>
      <option value="9">2009</option>
      <option value="10">2010</option>
      <option value="11">2011</option>
      <option value="12">2012</option>
      <option value="13">2013</option>
      <option value="14">2014</option>
      <option value="15">2015</option>
      <option value="16">2016</option>
      <option value="17">2017</option>
</select>
</TD></tr>
<TD>
</TD></tr></TABLE>
</form>

<SCRIPT LANGUAGE="JavaScript">
       

function floor(number)
{
  return Math.floor(number*Math.pow(10,2))/Math.pow(10,2);
}
 
function dosum()
{
  var mi = document.temps.IR.value / 1200;
  var base = 1;
  var mbase = 1 + mi;
  for (i=0; i<document.temps.YR.value * 12; i++)
  {
    base = base * mbase
  }
  document.temps.PI.value = floor(document.temps.LA.value * mi / ( 1 - (1/base)))
  document.temps.MT.value = floor(document.temps.AT.value / 12)
  document.temps.MI.value = floor(document.temps.AI.value / 12)
  var dasum = document.temps.LA.value * mi / ( 1 - (1/base)) +
        document.temps.AT.value / 12 +
        document.temps.AI.value / 12;
  document.temps.MP.value = floor(dasum);
}
 

</SCRIPT>
 
</head>
 
<body>
 
<Center>
</br><font size=3><b><b>Payment Calculators and Javascript Calculator</b></font><br>
<FORM NAME="temps">
 
<TABLE align = "center" border=20 cellspacing=0 cellpadding=2 bgcolor="#66FF33">
<TD>
Years <INPUT TYPE="TEXT" NAME="YR" onChange="dosum()" SIZE="6" VALUE="30">
Interest <INPUT TYPE="TEXT" NAME="IR" onChange="dosum()" SIZE="6" VALUE="8.0">
<TD>
Loan Amount <INPUT TYPE="TEXT" NAME="LA" onChange="dosum()" SIZE="6" VALUE="100000">
<TD>
Annual Tax <INPUT TYPE="TEXT" NAME="AT" onChange="dosum()" SIZE="6" VALUE="1000">
<TD>
Annual Insurance <INPUT TYPE="TEXT" NAME="AI" onChange="dosum()" SIZE="6" VALUE="300">
<TD ALIGN=CENTER>
<INPUT TYPE="BUTTON" VALUE="Calculate Now!" onClick="dosum()">
</TABLE>
<p>
<b>Results</b>
<p>
<TABLE align = "center" border=20 cellspacing=0 cellpadding=2 bgcolor="#66FF33">
<TD>Monthly Principal + Interest<TD><INPUT TYPE="TEXT" NAME="PI" SIZE="10">
<TD>Monthly Tax <TD><INPUT TYPE="TEXT" NAME="MT" SIZE="10">
<TD>Monthly Ins <TD><INPUT TYPE="TEXT" NAME="MI" SIZE="10">
<TD>Total Payment <TD><INPUT TYPE="TEXT" NAME="MP" SIZE="10">
</TABLE>
 
</FORM>
 
<p>
 
<br><br>
<font size="-1"> * The accuracy and applicability of this calculator are not guaranteed.</font><br>
<font size="1">
<a href="http://www.mortgage-calc.com/ewm_copyright.html" target="_top">
Copyright © EWM Calculators</a>, All Rights Reserved.</font><br>&nbsp;</p>
</body>
</html>


</body>
</html>

0
Comment
Question by:Draph_89
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 63

Assisted Solution

by:Zvonko
Zvonko earned 525 total points
ID: 16620972
It is bad that you have no experiance, but where is the question in upper posting? Or do you expect that someone does your job for free?
0
 
LVL 11

Expert Comment

by:mvan01
ID: 16621139
0
 
LVL 41

Assisted Solution

by:HonorGod
HonorGod earned 450 total points
ID: 16621353
It is quite clear, as you stated, that you don't have much experience.  I would suggest that you start with a simple HTML template, and add one thing at a time, testing as you go.  Here is a resonable starting place:

<html>
<head>
  <title>Credit card Entry and Mortage Calculator</title>
</head>
<body>

</body>
</html>

----------------------------------------------------------------------------------------------------
  Then, you can start adding things to the body to define the fields.
  When you add a field, use a browser (perhaps more than one) to verify that the field is displayed correctly.
  When you get to the point where you need to have field validation, start simple, and use the firefox javascript
  console to see any error messages that get generated.

  by the way, where are the "Federated States"?

  Good luck
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:Draph_89
ID: 16622872
My question is how can I clean up my Javascripts? I have tried to put function statements in before the Table and they have failed. So I have had to simply this. I would to see if someone can help create an array and validation functions for State, zip, birthday validation, credit card, etc. I have tried incorporation this function but it does not register in the webpage.

function checkForNumber(fieldValue) {
     var numberCheck = isNaN(fieldValue);
     if (numberCheck == true) {
           window.alert(“You must enter a numeric value!”);
           return false;
     }
}

if (document.forms[0].name_billing.value == “”
     || document.forms[0].address_billing.value == “”
     || document.forms[0].city_billing.value == “”
     || document.forms[0].state_billing.value == “”
     || document.forms[0].zip_billing.value == “”) {
     window.alert(“You must enter your billing information.”);
     return false;
}

else if (document.forms[0].area.value == “”
     || document.forms[0].exchange.value == “”
     || document.forms[0].phone.value == “”) {
     window.alert(“You must enter your telephone number.”);
     return false;
}


onchange=”return checkForNumber(this.value);

I have tried incorporation this function but it does not register in the webpage.

head>
     <title>Credit card Entry and Mortage Calculator</title>

     <script language="Javascript" type=”text/javascript”>
     <!-- HIDE FROM INCOMPATIBLE BROWSERS
     </script>

</form>
<h3 align= "center" font face="arial">Individual Address and Credit Card Form</h3>

</TABLE>            
<TABLE align = "center" border=20 cellspacing=0 cellpadding=2 bgcolor="#66FF33">
<tr valign=>
<TD>
     <font face="arial">First Name</font>
</TD>
<TD>
     <input type=text name="First Name" size=25,1 maxlength=25>
</TD></tr>
<tr>
<TD>
     <font face="arial">Last Name</font>
</TD>
<TD>
     <input type=text name="Last Name" size=25,1 maxlength=25>
</TD></tr>
<tr>
<TD>
     <font face="arial">Address</font>
</TD>
<TD>
     <input type=text name="Address" size=25,1 maxlength=25>
</TD></tr>
<tr>
<TD>
     <font face="arial">City</font>
</TD>
<TD>
     <input type=text name="City" size=25,1 maxlength=25>
</TD></tr>
<tr>
<TD>
     <font face="arial">State</font>
</TD>
<TD>
<select value="">
     <option value="" selected>Please Select</option>
     <option value="AK">Alaska</option>
     <option value="AL">Alabama</option>
     <option value="AR">Arkansas</option>
     <option value="AS">American Samoa</option>    
     <option value="AZ">Arizona</option>
     <option value="CA">California</option>
     <option value="CO">Colorada</option>
     <option value="CT">Conneticut</option>
     <option value="DC">District of Colombia</option>
     <option value="DE">Delaware</option>
     <option value="FL">Florida</option>
     <option value="FM">Federated States</option>
     <option value="GA">Georgia</option>
     <option value="GU">Guam</option>
     <option value="HI">Hawaii</option>
     <option value="IA">Iowa</option>
     <option value="ID">Idaho</option>
     <option value="IL">Illinois</option>
     <option value="IN">Indiana</option>
     <option value="KS">Kansas</option>
     <option value="KY">Kentucky</option>
     <option value="LA">Louisiana</option>
     <option value="MA">Massachusetts</option>
     <option value="MD">Maryland</option>
     <option value="ME">Maine</option>
     <option value="MI">Michigan</option>
     <option value="MN">Minnesota</option>
     <option value="MO">Missouri</option>
     <option value="MS">Mississippi</option>
     <option value="MT">Montana</option>
     <option value="NC">North Carolina</option>
     <option value="ND">North Dakota</option>
     <option value="NE">Nebraska</option>
     <option value="NH">New Hampshire</option>
     <option value="NJ">New Jersey</option>
     <option value="NM">New Mexico</option>
     <option value="NV">Nevada</option>
     <option value="NY">New York</option>
     <option value="OH">Ohio</option>
     <option value="OK">Oklahoma</option>
     <option value="OR">Oregon</option>
     <option value="PA">Pennsylvania</option>
     <option value="PR">Puerto Rico</option>
     <option value="RI">Rhode Island</option>
     <option value="SC">South Carolina</option>
     <option value="SD">South Dakota</option>
     <option value="TN">Tennessee</option>
     <option value="TX">Texas</option>
     <option value="UT">Utah</option>
     <option value="VI">Virgin Islands</option>
     <option value="VT">Vermont</option>
     <option value="VA">Virginia</option>
     <option value="WA">Washington</option>
     <option value="WI">Wisconsin</option>
     <option value="WV">West Virginia</option>
     <option value="WY">Wyoming</option>
</select>
</TD></tr>
<tr>
<TD>
     <font face="arial">Zip Code</font>
</TD>
<TD>
     <input type=text name="Zip" size=5,1 maxlength=5>
</TD></tr>
<TD>
     <font face="arial">Telephone (Area Code)</font>
</TD>
<TD>
     <input type=text name="Telephone" size=13,1 maxlength=13>
</TD></tr>
<TD>
     <font face="arial">Date of Birth</font>
</TD>
<TD>
0
 
LVL 11

Accepted Solution

by:
mvan01 earned 525 total points
ID: 16625011
Hi Draph_89,

Here is a bit of your code rearranged, to give you an example of where to put the various elements of your page.  Please read it, try it, and understand how it works (and what it does 'not' do).  Then you can add in other parts of your form and create code to handle that.  Keep your javascript functions in <head> </head> (not necessary, but keeps things clean).  Pay attention to matching opening and closing braces:  {...} .  Pay attention to capitalization (in this example, the name 'Zip' cannot be referred to as 'zip').

As a general approach, first, have an overall structure in mind (or written down!).  If you are new to a language or method, build your program or page up a bit at a time, working to understand each part as you add it, by making sure that it operates as desired.  Then add the next part, and so on.  Using blocks of existing code from others is a good way to learn, but seldom can be pasted in to work with your page without (a) a solid understanding of the various constructs and details of the programming language you're using or (b) working through the understanding, piece by piece, if you don't have the experience required for (a) yet.  I guess I'm saying: If you're inexperienced with the programming language, don't just 'use' a block of code, use it to first gain an understanding of how it works.

Peace and joy.  mvan


<html>
<head>
<title>mvan - Q_21840493 example</title>

<script language="JavaScript">

function checkForNumber(fieldValue) {
     var numberCheck = isNaN(fieldValue);
     if (numberCheck == true) {
           window.alert("You must enter a numeric value!");
           return false;
     }
}

function checkAllFields() {
     if (document.forms[0].Zip.value == "") {
          window.alert("You forgot to enter a zip code");
          return false;
     }
}

</script>

</head>
<body>
<h3 align= "center" font face="arial">Individual Address and Credit Card Form</h3>

<form name="address" onSubmit="checkAllFields();">
<TABLE align = "center" border=20 cellspacing=0 cellpadding=2 bgcolor="#66FF33">
   <tr>
      <TD>
         <font face="arial">Zip Code</font>
      </TD>
      <TD>
         <input type=text name="Zip" size=5,1 maxlength=5 onchange="return checkForNumber(this.value);">
      </TD>
   </tr>
</TABLE>
</form>

</body>
</html>
0
 
LVL 1

Author Comment

by:Draph_89
ID: 16631189
The Error checking is not working properly. I am wondering what I need to do to fix it. What is the difference between window.alert and alert?


<html>
<head>
<script language="Javascript" type = "text/javascript">
<!--
function customerObj() {
this.fname = "";
this.lname = "";
this.address = "";
this.city = "";
this.state = "";
this.zip = "";
this.telephone = "";
this.dob = "";
this.creditname = "";
this.creditnumber = "";
this.month = "";
this.year = "";
}
var newCust = new customerObj();
function createCust() {
newCust.fname = custform.fname.value;
newCust.lname = custform.lname.value;
newCust.address = custform.address.value;
newCust.city = custform.city.value;
newCust.state = custform.state.value;
newCust.zip = custform.zip.value
newCust.telephone = custform.telephone.value;
newCust.dob = custform.dob.value;
newCust.creditname = custform.creditname.value;
newCust.creditnumber = custform.creditnumber.value;
newCust.month = custform.month.value;
newCust.year = custform.year.value;
}
function cardSelection(){
var group = card;
for (var i=0; i<group.length; i++) {
      if (group[i].checked) break;
      }
      if (i==group.length) return false;
      else {return true;
      }
}
function DisplayErrors(){
if (CardSelection()==false)
alert("Please check the radio button \n for Credit Card Selection");
}
function ccvalid(creditnumber){
  var ccardnum  = isNaN(creditnumber);
 
  if (ccardnum == true){
    alert("Numerical value only.");
 return false;
  }
}

function validation() {
  var day = new day();
  day.setFullYear(custform[0].year.value,custorm[0].month.value);
  var day1 = new day1();
  var cardc;
 
  for (var a=0; a<3; a++) {
    if (custform[0].card[a].checked) {
      cardc = custform[0].card[a].value
    }
  }

  switch (cardc){
    case "American Express":
   if (custform[0].creditnumber.value.charAt(0) != 3){
     alert("American Express starts with 3.");
  return false;
   }
   break;
 case "visa":
   if (custform[0].creditnumber.value.charAt(0) != 4){
     alert("Visa tarts with 4.");
  return false;
   }
   break;
 case "Mastercard":
   if (custform[0].creditnumber.value.charAt(0) != 5){
     alert("Mastercard starts with 5.");
  return false;
   }
   break;
  }

  if (custform[0].month.value == ""
    || custform [0].year.value == "") {
 alert("Credit card expiration month and/or year not selected.");
 return false;
  }
  else if (day < day1) {
    alert("Credit card has expired!");
 return false;
  }
  else if (cardc == "American Express" && custform[0].creditnumber.value.length < 15){
 alert("American Express is 15 numbers.");
 return false;
  }
  else if (cardc == "Visa" && custform[0].creditnumber.value.length < 16){
 alert("Visa is 16 number.");
 return false;
  }
  else if (cardc == "Mastercard" && custform[0].creditnumber.value.length != 16){
    alert("Mastercard is 16 numbers.");
 return false;
  }
 
  else if (validation() == true)
    return true;
  return false;
}
 
//-->
</script>
</head>
<body>
      <title>Credit card Entry and Mortage Calculator</title>
<form name="custform">
<h3 align= "center" font face="arial">Individual Address and Credit Card Form</h3>

</TABLE>            
<TABLE align = "center" border=20 cellspacing=0 cellpadding=2 bgcolor="#66FF33">
<tr valign=>
<TD>
      <font face="arial">First Name</font>
</TD>
<TD>
      <input type="text" name="fname" size=25,1 maxlength=25>
</TD></tr>
<tr>
<TD>
      <font face="arial">Last Name</font>
</TD>
<TD>
      <input type="text" name="lname" size=25,1 maxlength=25>
</TD></tr>
<tr>
<TD>
      <font face="arial">Address</font>
</TD>
<TD>
      <input type="text" name="address" size=25,1 maxlength=25>
</TD></tr>
<tr>
<TD>
      <font face="arial">City</font>
</TD>
<TD>
      <input type="text" name="city" size=25,1 maxlength=25>
</TD></tr>
<tr>
<TD>
      <font face="arial">State</font>
</TD>
<TD>
<select name="state">
      <option value="" selected>Please Select</option>
      <option value="AK">Alaska</option>
      <option value="AL">Alabama</option>
      <option value="AR">Arkansas</option>
      <option value="AS">American Samoa</option>      
      <option value="AZ">Arizona</option>
      <option value="CA">California</option>
      <option value="CO">Colorada</option>
      <option value="CT">Conneticut</option>
      <option value="DC">District of Colombia</option>
      <option value="DE">Delaware</option>
      <option value="FL">Florida</option>
      <option value="FM">Federated States</option>
      <option value="GA">Georgia</option>
      <option value="GU">Guam</option>
      <option value="HI">Hawaii</option>
      <option value="IA">Iowa</option>
      <option value="ID">Idaho</option>
      <option value="IL">Illinois</option>
      <option value="IN">Indiana</option>
      <option value="KS">Kansas</option>
      <option value="KY">Kentucky</option>
      <option value="LA">Louisiana</option>
      <option value="MA">Massachusetts</option>
      <option value="MD">Maryland</option>
      <option value="ME">Maine</option>
      <option value="MI">Michigan</option>
      <option value="MN">Minnesota</option>
      <option value="MO">Missouri</option>
      <option value="MS">Mississippi</option>
      <option value="MT">Montana</option>
      <option value="NC">North Carolina</option>
      <option value="ND">North Dakota</option>
      <option value="NE">Nebraska</option>
      <option value="NH">New Hampshire</option>
      <option value="NJ">New Jersey</option>
      <option value="NM">New Mexico</option>
      <option value="NV">Nevada</option>
      <option value="NY">New York</option>
      <option value="OH">Ohio</option>
      <option value="OK">Oklahoma</option>
      <option value="OR">Oregon</option>
      <option value="PA">Pennsylvania</option>
      <option value="PR">Puerto Rico</option>
      <option value="RI">Rhode Island</option>
      <option value="SC">South Carolina</option>
      <option value="SD">South Dakota</option>
      <option value="TN">Tennessee</option>
      <option value="TX">Texas</option>
      <option value="UT">Utah</option>
      <option value="VI">Virgin Islands</option>
      <option value="VT">Vermont</option>
      <option value="VA">Virginia</option>
      <option value="WA">Washington</option>
      <option value="WI">Wisconsin</option>
      <option value="WV">West Virginia</option>
      <option value="WY">Wyoming</option>
</select>
</TD></tr>
<tr>
<TD>
      <font face="arial">Zip Code</font>
</TD>
<TD>
      <input type="text" name="zip" size=5,1 maxlength=5>
</TD></tr>
<TD>
      <font face="arial">Telephone (Area Code)</font>
</TD>
<TD>
      <input type="text" name="telephone" size=13,1 maxlength=13>
</TD></tr>
<TD>
      <font face="arial">Date of Birth mmddyyyy</font>
</TD>
<TD>
         <input type="text" name="dob" size=8,1 maxlength=8>
<TD>

</select>
</TD></tr>
<TD>
      <font face="arial">Credit Card Number</font>
<TD>
      <input type="text" name="CreditNumber" size=16,1 maxlength=16>
&nbsp:
      
<TD>
      <font face="arial">Credit Card Company</font>
</TD>
&nbsp;
<TD>
 <input type="radio" name="card" value="American Express">American Express
 <input type="radio" name="card" value="Visa">Visa
 <input type="radio" name="card" value="Mastercard">Mastercard
<TD>
&nbsp:
      <font face="arial">Expiration</font>
<select name="month">
      <option value=""></option>
      <option value="JAN">January</option>
      <option value="FEB">February</option>
      <option value="MAR">March</option>
      <option value="APR">April</option>
      <option value="MAY">May</option>
      <option value="JUN">June</option>
      <option value="JUL">July</option>
      <option value="AUG">August</option>
      <option value="SEP">September</option>
      <option value="OCT">October</option>
      <option value="NOV">November</option>
      <option value="DEC">December</option>
</select>
&nbsp:
<select name="year">
        <option value=""></option>
      <option value="2004">2004</option>
      <option value="2005">2005</option>
      <option value="2006">2006</option>
      <option value="2007">2007</option>
      <option value="2008">2008</option>
      <option value="2009">2009</option>
      <option value="2010">2010</option>
      
</select>
&nbsp;
</TD></tr></TABLE>
<input type="submit" value="Submit" OnClick="validation()"></p>
</form>

<SCRIPT LANGUAGE="JavaScript">
       

function floor(number)
{
  return Math.floor(number*Math.pow(10,2))/Math.pow(10,2);
}
 
function dosum()
{
  var mi = document.temps.IR.value / 1200;
  var base = 1;
  var mbase = 1 + mi;
  for (i=0; i<document.temps.YR.value * 12; i++)
  {
    base = base * mbase
  }
  document.temps.PI.value = floor(document.temps.LA.value * mi / ( 1 - (1/base)))
  document.temps.MT.value = floor(document.temps.AT.value / 12)
  document.temps.MI.value = floor(document.temps.AI.value / 12)
  var dasum = document.temps.LA.value * mi / ( 1 - (1/base)) +
        document.temps.AT.value / 12 +
        document.temps.AI.value / 12;
  document.temps.MP.value = floor(dasum);
}
 

</SCRIPT>
 
</head>
 
<body>
 
<Center>
</br><font size=3><b><b>Payment Calculators and Javascript Calculator</b></font><br>
<FORM NAME="temps">
 
<TABLE align = "center" border=20 cellspacing=0 cellpadding=2 bgcolor="#66FF33">
<TD>
Years <INPUT TYPE="TEXT" NAME="YR" onChange="dosum()" SIZE="6" VALUE="30">
Interest <INPUT TYPE="TEXT" NAME="IR" onChange="dosum()" SIZE="6" VALUE="8.0">
<TD>
Loan Amount <INPUT TYPE="TEXT" NAME="LA" onChange="dosum()" SIZE="6" VALUE="100000">
<TD>
Annual Tax <INPUT TYPE="TEXT" NAME="AT" onChange="dosum()" SIZE="6" VALUE="1000">
<TD>
Annual Insurance <INPUT TYPE="TEXT" NAME="AI" onChange="dosum()" SIZE="6" VALUE="300">
<TD ALIGN=CENTER>
<INPUT TYPE="BUTTON" VALUE="Calculate Now!" onClick="dosum()">
</TABLE>
<p>
<b>Results</b>
<p>
<TABLE align = "center" border=20 cellspacing=0 cellpadding=2 bgcolor="#66FF33">
<TD>Monthly Principal + Interest<TD><INPUT TYPE="TEXT" NAME="PI" SIZE="10">
<TD>Monthly Tax <TD><INPUT TYPE="TEXT" NAME="MT" SIZE="10">
<TD>Monthly Ins <TD><INPUT TYPE="TEXT" NAME="MI" SIZE="10">
<TD>Total Payment <TD><INPUT TYPE="TEXT" NAME="MP" SIZE="10">
</TABLE>
 
</FORM>
 
<p>
 
<br><br>
<font size="-1"> * The accuracy and applicability of this calculator are not guaranteed.</font><br>
<font size="1">
<a href="http://www.mortgage-calc.com/ewm_copyright.html" target="_top">
Copyright © EWM Calculators</a>, All Rights Reserved.</font><br>&nbsp;</p>
</body>
</html>


</body>
</html>
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 16632407
Your ccvalid() function will return false, but never returns true.

function validation()
 - only returns false
 - contains a recursive call - which is not what you want.

Your html ends with 2 copies of:

</body>
</html>

0
 
LVL 11

Expert Comment

by:mvan01
ID: 16632964
alert(); is just a short way to say window.alert();

The window designation is optional.  They will both behave the same.

Peace and joy.  mvan
0
 
LVL 1

Author Comment

by:Draph_89
ID: 16849830
Thanks everyone for you help. I do appreciate your assistance. You all were right about do more with the program that I did do. Thanks.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Learn about the eCommerce marketing trends for the year ahead.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question