Solved

Validating Numbers in A Form

Posted on 2004-10-15
11
187 Views
Last Modified: 2012-06-27
I am not very good at javascript.  I have created a form in Dreamweaver where users enter their checking information.  I need a script that validates a routing number.  Actually, it just needs to verify that the routing number is nine digits.
Can someone help?
0
Comment
Question by:rachelcjanssen
  • 6
  • 3
  • 2
11 Comments
 
LVL 13

Expert Comment

by:StormyWaters
ID: 12324644
<script language="javascript">
function validate(form) {
  return /\d{9}/.test(form.routenumber.value);
}
</script>

then, put this in the <form> tag:
onsubmit="return validate(this)"

This assumes that the name of the textbox that contains the routing number is called routenumber. Change that to what you have it named.
0
 

Author Comment

by:rachelcjanssen
ID: 12328863
I tried this exactly as you said and it didn't seem to work.  My form name is CheckPay.  
I have another script that validates the form when the user clicks the submit button.  Does that make a difference?
0
 
LVL 13

Expert Comment

by:StormyWaters
ID: 12328934
You could just add that little snippet to your validation function.
This part:
/\d{9}/.test(form.routenumber.value)
0
 
LVL 1

Expert Comment

by:prabhukrishnan
ID: 12330384
Please test the code below .
I have written a Javascript function  genValidateNumeric that validates the routing number field value for any invalid characters and for length of 9 digits.

Hope this helps

Prabhu
/*******************************************************************/
<HTML>
<HEAD>
<script language="javascript">
      function genValidateNumeric(data)
      {
            var status = true;
            var n_numStr = "0123456789";
            var numStr;
            var thisChar;
            var decimalPtCtr = 0;
            var i;
            var errText;
            
            numStr = n_numStr;
            
            for ( i=0; i<data.length; i++)
            {
                thisChar = data.substring( i, i+1 );
            
                if (numStr.indexOf( thisChar ) == -1)
                {
                    errText = "This field contains non-numeric information.";
                    status = false;
                    break;
                }
            }
            
            if (status != true)
            {
                  alert( errText );
                  return status;      
            }
            
            if(data.length != 9)
            {
                  status = false;
                  alert("Routing number does not have 9 digits")
                  return status
            }
            
            return status;
      }

      function validate()
      {
            var value = document.forms['SOMEFORM'].elements['routingnumber'].value;
            if(genValidateNumeric(value))
            {
                  document.forms['SOMEFORM'].submit();
            }
      }
</script>
</head>
<BODY>
<FORM NAME="SOMEFORM" action="/SomeCGIScript" METHOD="POST">

Routing number <input type="text" name="routingnumber" value="" length=12">
<br>
<input type=button value="Submit" onClick="javascript:validate()">
</FORM>
</BODY>
<HTML>


0
 
LVL 13

Expert Comment

by:StormyWaters
ID: 12330478
Isn't that just a bit inefficient?
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Expert Comment

by:prabhukrishnan
ID: 12331087

The flexibility the writing a separate function like genValidateNumeric is in the reusability.
If one wants to check for specific characters like @ etc , we can modify the function and pass additional parameters to specific what sort of validation to be performed by the function.

Prabhu

0
 
LVL 13

Expert Comment

by:StormyWaters
ID: 12332736
You could do that just as easily with a regular expression.

/[0-9@]{9}/ would test for the @ character as well.

Want to test for just 8 characters?
/[0-9@]{8}/

0
 

Author Comment

by:rachelcjanssen
ID: 12334273
I am going to post the full thing here because I haven't gotten any of your suggestions to work and I am positive I am doing something wrong.

Currently, the "BANK ROUTING     :" field is required but I can't control whether the user enters a number or how many digits the number is.

Sorry, if this very annoying.  I don't seem to grasp the javascript language quite yet.

I increased the points a bit.  Please don't give up on me quite yet.  Thank you for your help.

Rachel

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Check Pay - La Maison du Bayou</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--

function ShowMenu(URL, WinTitle, WinWidth, WinHeight, WinLeft, WinTop){
      attr = "resizable=no,width=" + WinWidth + ",height=" + WinHeight + ",screenX=" + WinLeft + ",screenY=" + WinTop + ",left=" + WinLeft + ",top=" + WinTop + "";
      msgWindow=open(URL, WinTitle, attr);
      
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+s)}
  document.MM_returnValue = (s=='');
}
//-->
</script>
</head>

<body>

<table width="478" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
  <!--DWLayoutTable-->
  <tr>
    <td width="478" height="16" valign="top"><div align="center"><font size="3" face="Arial, Helvetica, sans-serif"><strong>Online
        Check Payment Form</strong></font></div></td>
  </tr>
  <tr>
    <td height="1111" valign="top" bgcolor="#CCCCCC"> <div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><strong>To
        pay by check:<br>
        complete for below and click submit when you are finished.</strong></font></div>
      <form action="https://www.form-mail.com/a.cgi?140-checkpay" method="POST" name="CheckPay" id="CheckPay">
        <p><strong><font size="2" face="Arial, Helvetica, sans-serif">STUDENT
          INFORMATION :</font></strong></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">Last Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input name="LAST NAME     :" type="text" id="LAST NAME     :" size="20">
          </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif"> First Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input name="FIRST NAME     :" type="text" id="FIRST NAME     :" size="20">
          </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">&nbsp;Middle Initial&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          &nbsp;&nbsp;&nbsp;
          <input name="MIDDLE NAME:            " type="text" id="MIDDLE NAME:            " size="3">
          </font></p>
        <p><font size="2" face="Arial, Helvetica, sans-serif"><strong> BILLING
          ADDRESS:</strong></font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">Street:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input name="STREET:            " type="text" id="STREET:            " size="26">
          </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">City: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input name="CITY     :" type="text" id="CITY     :" size="26">
          </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">State:&nbsp;&nbsp;&nbsp;
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          &nbsp;
          <select name="HOME STATE:            " id="HOME STATE:            ">
            <option selected> </option>
            <option>AL - Alabama</option>
            <option>AK - Alaska</option>
            <option>AZ - Arizona</option>
            <option>AR - Arkansas</option>
            <option>CA - California</option>
            <option>CO - Colorado</option>
            <option>CT - Connecticut</option>
            <option>DE - Delaware</option>
            <option>DC - District of Columbia</option>
            <option>FL - Florida</option>
            <option>GA - Georgia</option>
            <option>HI - Hawaii</option>
            <option>ID - Idaho</option>
            <option>IL - Illinois</option>
            <option>IN - Indiana</option>
            <option>IA - Iowa</option>
            <option>KS - Kansas</option>
            <option>KY - Kentucky</option>
            <option>LA - Louisiana</option>
            <option>ME - Maine</option>
            <option>MD - Maryland</option>
            <option>MA - Massachusetts</option>
            <option>MI - Michigan</option>
            <option>MN - Minnesota</option>
            <option>MS - Mississippi</option>
            <option>MO - Missouri</option>
            <option>MT - Montana</option>
            <option>NE - Nebraska</option>
            <option>NV - Nevada</option>
            <option>NH - New Hampshire</option>
            <option>NJ - New Jersey</option>
            <option>NM - New Mexico</option>
            <option>NY - New York</option>
            <option>NC - North Carolina</option>
            <option>ND - North Dakota</option>
            <option>OH - Ohio</option>
            <option>OK - Oklahoma</option>
            <option>OR - Oregon</option>
            <option>PA - Pennsylvania</option>
            <option>RI - Rhode Island</option>
            <option>SC - South Carolina</option>
            <option>SD - South Dakota</option>
            <option>TN - Tennessee</option>
            <option>TX - Texas</option>
            <option>UT - Utah</option>
            <option>VT - Vermont</option>
            <option>VA - Virginia</option>
            <option>WA - Washington</option>
            <option>WV - West Virginia</option>
            <option>WI - Wisconsin</option>
            <option>WY - Wyoming</option>
          </select>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">Zip:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input name="ZIP:            " type="text" id="ZIP:            " size="5" maxlength="5">
          </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">Email: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input name="EMAIL:            " type="text" id="EMAIL:            ">
          </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif"> Phone:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input name="HOME PHONE:            " type="text" id="HOME PHONE:            " size="15">
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></p>
        <p><font size="2" face="Arial, Helvetica, sans-serif"><strong>ACCOUNT
          INFORMATION:</strong></font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">Date:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <label>
          <input name="DATE     :" type="text" id="DATE     :">
          </label>
          </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">
          <label>Check Number:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input name="CHECK NUMBER     :" type="text" id="CHECK NUMBER     :">
          <a  href="javascript:ShowMenu('http://www.lamaisondubayou.com/window1.htm','window1',432,192,500,300)">find
          your check number</a></label>
          </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">
          <label>Amount: </label>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$
          <label>
          <input name="AMOUNT     :" type="text" id="AMOUNT     :">
          US Dollars</label>
          </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">Payee:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          &nbsp;&nbsp;
          <label>
          <input name="PAYEE     :" type="text" id="PAYEE     :" value="La Maison du Bayou">
          Property Name</label>
          </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">
          <label>Memo Field:</label>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <label>
          <input name="MEMO     :" type="text" id="MEMO     :">
          </label>
          </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">
          <label>Bank Routing Number:</label>
          &nbsp;
          <label>
          <input name="BANK ROUTING#     :" type="text" id="BANK ROUTING#     :" >
          <a href="javascript:ShowMenu('http://www.lamaisondubayou.com/window1.htm','window1',432,192,500,300)">find
          your routing number</a></label>
          <label> </label>
          </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">
          <label>Account Number:</label>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <label>
          <input name="ACCOUNT#     :" type="text" id="ACCOUNT#     :">
          <a href="javascript:ShowMenu('http://www.lamaisondubayou.com/window1.htm','window1',432,192,500,300)">find
          your account number</a> </label>
          <label> </label>
          </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">
          <label>Bank Name:</label>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <label>
          <input name="BANK NAME     :" type="text" id="BANK NAME     :">
          </label>
          </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif">
          <label>Bank City:</label>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <label>
          <input name="BANK CITY     :" type="text" id="BANK CITY     :">
          </label>
          </font></p>
        <p><font size="1" face="Arial, Helvetica, sans-serif"> Bank State:&nbsp;&nbsp;&nbsp;
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          &nbsp;
          <select name="BANK STATE     :" id="BANK STATE     :">
            <option selected> </option>
            <option>AL - Alabama</option>
            <option>AK - Alaska</option>
            <option>AZ - Arizona</option>
            <option>AR - Arkansas</option>
            <option>CA - California</option>
            <option>CO - Colorado</option>
            <option>CT - Connecticut</option>
            <option>DE - Delaware</option>
            <option>DC - District of Columbia</option>
            <option>FL - Florida</option>
            <option>GA - Georgia</option>
            <option>HI - Hawaii</option>
            <option>ID - Idaho</option>
            <option>IL - Illinois</option>
            <option>IN - Indiana</option>
            <option>IA - Iowa</option>
            <option>KS - Kansas</option>
            <option>KY - Kentucky</option>
            <option>LA - Louisiana</option>
            <option>ME - Maine</option>
            <option>MD - Maryland</option>
            <option>MA - Massachusetts</option>
            <option>MI - Michigan</option>
            <option>MN - Minnesota</option>
            <option>MS - Mississippi</option>
            <option>MO - Missouri</option>
            <option>MT - Montana</option>
            <option>NE - Nebraska</option>
            <option>NV - Nevada</option>
            <option>NH - New Hampshire</option>
            <option>NJ - New Jersey</option>
            <option>NM - New Mexico</option>
            <option>NY - New York</option>
            <option>NC - North Carolina</option>
            <option>ND - North Dakota</option>
            <option>OH - Ohio</option>
            <option>OK - Oklahoma</option>
            <option>OR - Oregon</option>
            <option>PA - Pennsylvania</option>
            <option>RI - Rhode Island</option>
            <option>SC - South Carolina</option>
            <option>SD - South Dakota</option>
            <option>TN - Tennessee</option>
            <option>TX - Texas</option>
            <option>UT - Utah</option>
            <option>VT - Vermont</option>
            <option>VA - Virginia</option>
            <option>WA - Washington</option>
            <option>WV - West Virginia</option>
            <option>WI - Wisconsin</option>
            <option>WY - Wyoming</option>
          </select>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></p>
        <p><font size="2" face="Arial, Helvetica, sans-serif"><strong>Checking
          <font color="#FF0000"> <em>Accept</em></font> below indicates that you
          have filled out this form, and agree to its use for the purpose indicated
          herein.</strong></font></p>
        <p align="center">
          <label><strong><font size="2" face="Arial, Helvetica, sans-serif">
          <input type="radio" name="ACCEPT AGREEMENT:            " value="I accept">
          I accept</font></strong></label>
          <strong><font size="2" face="Arial, Helvetica, sans-serif"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <label>
          <input type="radio" name="ACCEPT AGREEMENT:            " value="I do not accept">
          I do not accept</label>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date:
          <input name="DATE OF ACCEPTANCE:            " type="text" id="DATE OF ACCEPTANCE:    ">
          </font></strong></p>
        <p align="center"><font size="1" face="Arial, Helvetica, sans-serif">
          <input name="Submit" type="submit" onClick="YY_checkform('CheckPay','ACCEPT AGREEMENT:            [0]','#q','2','Please indicate whether you accept the agreement.','ACCEPT AGREEMENT:            [1]','#q','2','Please indicate whether you accept the agreement.','LAST NAME     :','#q','0','Please enter last name.','FIRST NAME     :','#q','0','Please enter first name.','STREET:            ','#q','0','Please enter street address.','CITY     :','#q','0','Please enter city.','ZIP:            ','#q','0','Please enter zip code.','EMAIL:            ','S','2','Please enter email address.','HOME PHONE:            ','#q','0','Please enter phone number.','DATE     :','#q','0','Please enter date.','CHECK NUMBER     :','#q','0','Please enter check number.','AMOUNT     :','#q','0','Please enter payment amount.','PAYEE     :','#q','0','Please enter payee name.','BANK ROUTING#     :','#q','0','Please enter 9 digit routing number.','ACCOUNT#     :','#q','0','Please enter checking account number.','BANK NAME     :','#q','0','Please enter bank name.','BANK CITY     :','#q','0','Please enter bank city.','DATE OF ACCEPTANCE:    ','#q','0','Please enter date.');return document.MM_returnValue" value="Submit">
          <br>
          </font></p>
      </form></td>
  </tr>
</table>
</body>
</html>
0
 
LVL 13

Expert Comment

by:StormyWaters
ID: 12334532
You DEFINITELY need to rethink your form.
I've cleaned up the syntax of it. Now... what elements are required?
0
 
LVL 13

Accepted Solution

by:
StormyWaters earned 400 total points
ID: 12334699
Okay, I sort of deciphered the function. Here is a MUCH cleaner, XHTML compatible version of your form with a better validation function.

For the date fields, you can have these automatically contain today's date. Let me know.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Check Pay - La Maison du Bayou</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style>
label {
  display:block;
  width:150px;
  float:left;
  clear:both;
}
form {
  width:500px;
}
</style>
</head>
<body>
<script language="javascript">
function validate(form) {
  var errMsg = new Array();
  errMsg["lastname"] = "Please enter your last name.";
  errMsg["firstname"] = "Please enter your first name.";
  errMsg["street"] = "Please enter your street address.";
  errMsg["city"] = "Please enter your city.";
  errMsg["email"] = "Please enter your e-mail address.";
  errMsg["phone"] = "Please enter your phone number.";
  errMsg["date"] = "Please enter the date.";
  errMsg["checknum"] = "Please enter your check number.";
  errMsg["amount"] = "Please enter the payment amount.";
  errMsg["payee"] = "Please enter the name of the payee.";
  errMsg["routingnumber"] = "Please enter your 9-digit routing number.";
  errMsg["accountnumber"] = "Please enter your checking account number.";
  errMsg["bankname"] = "Please enter your bank name.";
  errMsg["bankcity"] = "Please enter your bank city.";
  errMsg["dateaccepted"] = "Please enter your acceptance date.";
  var errors = "";
  for(var i in errMsg) {
    if(form.elements[i].value == "") {
        errors += "* "+errMsg[i] + "\n";
      }
  }
  if(!/\d{9}/.test(form.routingnumber.value) && form.routingnumber.value != '') {
    errors += "* The routing number must contain 9 digits.\n";
  }
  if(!form.accept.checked) {
    errors += "* Please indicate that you accept the agreement.\n";
  }
  if(errors != "") {
    alert(errors);
      return false;
  } else {
    return true;
  }
}
</script>
<form name="checkpay" onsubmit="return validate(this)">
  <fieldset>
  <legend>Student Information</legend>
  <label for="lastname">Last Name</label><input type="text" name="lastname" id="lastname" /><br/>
  <label for="firstname">First Name</label><input type="text" name="firstname" id="firstname" /><br/>
  <label for="middlename">Middle Initial</label><input type="text" name="middlename" id="middlename"  size="3"/>
  </fieldset>
  <fieldset>
  <legend>Billing Address</legend>
  <label for="street">Street</label><input type="text" name="street" id="street" /><br/>
  <label for="city">City</label><input type="text" name="city" id="city" /><br/>
  <label for="state">State</label>
  <select name="state" id="state">
    <option selected="true">---</option>
    <option>AL - Alabama</option>
    <option>AK - Alaska</option>
    <option>AZ - Arizona</option>
    <option>AR - Arkansas</option>
    <option>CA - California</option>
    <option>CO - Colorado</option>
    <option>CT - Connecticut</option>
    <option>DE - Delaware</option>
    <option>DC - District of Columbia</option>
    <option>FL - Florida</option>
    <option>GA - Georgia</option>
    <option>HI - Hawaii</option>
    <option>ID - Idaho</option>
    <option>IL - Illinois</option>
    <option>IN - Indiana</option>
    <option>IA - Iowa</option>
    <option>KS - Kansas</option>
    <option>KY - Kentucky</option>
    <option>LA - Louisiana</option>
    <option>ME - Maine</option>
    <option>MD - Maryland</option>
    <option>MA - Massachusetts</option>
    <option>MI - Michigan</option>
    <option>MN - Minnesota</option>
    <option>MS - Mississippi</option>
    <option>MO - Missouri</option>
    <option>MT - Montana</option>
    <option>NE - Nebraska</option>
    <option>NV - Nevada</option>
    <option>NH - New Hampshire</option>
    <option>NJ - New Jersey</option>
    <option>NM - New Mexico</option>
    <option>NY - New York</option>
    <option>NC - North Carolina</option>
    <option>ND - North Dakota</option>
    <option>OH - Ohio</option>
    <option>OK - Oklahoma</option>
    <option>OR - Oregon</option>
    <option>PA - Pennsylvania</option>
    <option>RI - Rhode Island</option>
    <option>SC - South Carolina</option>
    <option>SD - South Dakota</option>
    <option>TN - Tennessee</option>
    <option>TX - Texas</option>
    <option>UT - Utah</option>
    <option>VT - Vermont</option>
    <option>VA - Virginia</option>
    <option>WA - Washington</option>
    <option>WV - West Virginia</option>
    <option>WI - Wisconsin</option>
    <option>WY - Wyoming</option>
  </select>
  <br/>
  <label for="zip">Zip</label><input type="text" name="zip" id="zip"  size="5"/><br/>
  <label for="email">E-mail Address</label><input type="text" name="email" id="email" /><br/>
  <label for="phone">Phone Number</label><input type="text" name="phone" id="phone" />
  </fieldset>
  <fieldset>
  <legend>Account Information</legend>
  <label for="Date">Date</label><input type="text" name="date" id="date" /><br/>
  <label for="checknum">Check Number</label><input type="text" name="checknum" id="checknum" /><br/>
  <label for="amount">Amount $</label><input type="text" name="amount"/>(USD)<br/>
  <label for="payee">Payee</label><input type="text" name="payee" id="payee"  value="La Maison du Bayou"/>(Property Name)<br/>
  <label for="memofield">Memo Field</label><input type="text" name="memofield" id="memofield" /><br/>
  <label for="routingnumber">Bank Routing Number</label><input type="text" name="routingnumber" id="routingnumber" /><br/>
  <label for="accountnumber">Account Number</label><input type="text" name="accountnumber" id="accountnumber" /><br/>
  <label for="bankname">Bank Name</label><input type="text" name="bankname" id="bankname" /><br/>
  <label for="bankcity">Bank City</label><input type="text" name="bankcity" id="bankcity" /><br/>
  <label>Bank State
  <select name="bankstate">
    <option selected="true">---</option>
    <option>AL - Alabama</option>
    <option>AK - Alaska</option>
    <option>AZ - Arizona</option>
    <option>AR - Arkansas</option>
    <option>CA - California</option>
    <option>CO - Colorado</option>
    <option>CT - Connecticut</option>
    <option>DE - Delaware</option>
    <option>DC - District of Columbia</option>
    <option>FL - Florida</option>
    <option>GA - Georgia</option>
    <option>HI - Hawaii</option>
    <option>ID - Idaho</option>
    <option>IL - Illinois</option>
    <option>IN - Indiana</option>
    <option>IA - Iowa</option>
    <option>KS - Kansas</option>
    <option>KY - Kentucky</option>
    <option>LA - Louisiana</option>
    <option>ME - Maine</option>
    <option>MD - Maryland</option>
    <option>MA - Massachusetts</option>
    <option>MI - Michigan</option>
    <option>MN - Minnesota</option>
    <option>MS - Mississippi</option>
    <option>MO - Missouri</option>
    <option>MT - Montana</option>
    <option>NE - Nebraska</option>
    <option>NV - Nevada</option>
    <option>NH - New Hampshire</option>
    <option>NJ - New Jersey</option>
    <option>NM - New Mexico</option>
    <option>NY - New York</option>
    <option>NC - North Carolina</option>
    <option>ND - North Dakota</option>
    <option>OH - Ohio</option>
    <option>OK - Oklahoma</option>
    <option>OR - Oregon</option>
    <option>PA - Pennsylvania</option>
    <option>RI - Rhode Island</option>
    <option>SC - South Carolina</option>
    <option>SD - South Dakota</option>
    <option>TN - Tennessee</option>
    <option>TX - Texas</option>
    <option>UT - Utah</option>
    <option>VT - Vermont</option>
    <option>VA - Virginia</option>
    <option>WA - Washington</option>
    <option>WV - West Virginia</option>
    <option>WI - Wisconsin</option>
    <option>WY - Wyoming</option>
  </select>
  </label>
  </fieldset>
  <p>Checking accept below indicates that you have filled out this form, and agree to its use for the purpose indicated herein.</p>
  <label for="accept"><input type="checkbox" name="accept" id="accept" />I accept</label><br/>
  <label for="dateaccepted">Date</label><input type="text" name="dateaccepted" id="dateaccepted" />
  <input type="submit" value="Submit"/>
</form>
</body>
</html>
0
 

Author Comment

by:rachelcjanssen
ID: 12335053
I am increasing points for your amazing efforts and great results.  

I am going to post a new question and hope you can answer it as well.

I have also posted two questions about xml - flash - actionscripting

http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_21171758.html

http://www.experts-exchange.com/Web/Web_Languages/Q_21171759.html
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now