473,320 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to validate a form with Date of Birth and Preferred Insurance information

Please help, I can't validate the Date of Birth and Preferred Insurance Field

The javascript:

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/JavaScript">
  2.  
  3. <!--
  4. function MM_findObj(n, d) { //v4.01
  5.   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  6.     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  7.   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  8.   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  9.   if(!x && d.getElementById) x=d.getElementById(n); return x;
  10. }
  11.  
  12. function MM_validateForm() { //v4.0
  13.   var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  14.   for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
  15.     if (val) { nm=val.name; if ((val=val.value)!="") {
  16.       if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
  17.         if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
  18.       } else if (test!='R') { num = parseFloat(val);
  19.         if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
  20.         if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
  21.           min=test.substring(8,p); max=test.substring(p+1);
  22.           if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
  23.     } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  24.   } if (errors) alert('The following error(s) occurred:\n'+errors);
  25.   document.MM_returnValue = (errors == '');
  26. }
  27.  
  28. //-->
  29. </script>

THE FORM:
Expand|Select|Wrap|Line Numbers
  1.  <form method="POST" action="contactf1.asp">
  2.    <p>Fields marked (*) are required
  3.   </p>
  4.    <table width="642" border="0">
  5.      <tr>
  6.        <td width="155">Full Name: (*) </td>
  7.        <td width="296"><input type="text" name="Name"></td>
  8.        <td width="177" rowspan="14">&nbsp;</td>
  9.      </tr>
  10.      <tr>
  11.        <td>Date of Birth: (*) </td>
  12.        <td><select name="DateOfBirth_Month">
  13.     <option> - Month - </option>
  14.     <option value="January">January</option>
  15.     <option value="Febuary">Febuary</option>
  16.     <option value="March">March</option>
  17.     <option value="April">April</option>
  18.     <option value="May">May</option>
  19.     <option value="June">June</option>
  20.     <option value="July">July</option>
  21.     <option value="August">August</option>
  22.     <option value="September">September</option>
  23.     <option value="October">October</option>
  24.     <option value="November">November</option>
  25.     <option value="December">December</option>
  26. </select>
  27.  
  28. <select name="DateOfBirth_Day">
  29.     <option> - Day - </option>
  30.     <option value="1">1</option>
  31.     <option value="2">2</option>
  32.     <option value="3">3</option>
  33.     <option value="4">4</option>
  34.     <option value="5">5</option>
  35.     <option value="6">6</option>
  36.     <option value="7">7</option>
  37.     <option value="8">8</option>
  38.     <option value="9">9</option>
  39.     <option value="10">10</option>
  40.     <option value="11">11</option>
  41.     <option value="12">12</option>
  42.     <option value="13">13</option>
  43.     <option value="14">14</option>
  44.     <option value="15">15</option>
  45.     <option value="16">16</option>
  46.     <option value="17">17</option>
  47.     <option value="18">18</option>
  48.     <option value="19">19</option>
  49.     <option value="20">20</option>
  50.     <option value="21">21</option>
  51.     <option value="22">22</option>
  52.     <option value="23">23</option>
  53.     <option value="24">24</option>
  54.     <option value="25">25</option>
  55.     <option value="26">26</option>
  56.     <option value="27">27</option>
  57.     <option value="28">28</option>
  58.     <option value="29">29</option>
  59.     <option value="30">30</option>
  60.     <option value="31">31</option>
  61. </select>
  62.  
  63. <select name="DateOfBirth_Year">
  64.     <option> - Year - </option>
  65.     <option value="2004">2004</option>
  66.     <option value="2003">2003</option>
  67.     <option value="2002">2002</option>
  68.     <option value="2001">2001</option>
  69.     <option value="2000">2000</option>
  70.     <option value="1999">1999</option>
  71.     <option value="1998">1998</option>
  72.     <option value="1997">1997</option>
  73.     <option value="1996">1996</option>
  74.     <option value="1995">1995</option>
  75.     <option value="1994">1994</option>
  76.     <option value="1993">1993</option>
  77.     <option value="1992">1992</option>
  78.     <option value="1991">1991</option>
  79.     <option value="1990">1990</option>
  80.     <option value="1989">1989</option>
  81.     <option value="1988">1988</option>
  82.     <option value="1987">1987</option>
  83.     <option value="1986">1986</option>
  84.     <option value="1985">1985</option>
  85.     <option value="1984">1984</option>
  86.     <option value="1983">1983</option>
  87.     <option value="1982">1982</option>
  88.     <option value="1981">1981</option>
  89.     <option value="1980">1980</option>
  90.     <option value="1979">1979</option>
  91.     <option value="1978">1978</option>
  92.     <option value="1977">1977</option>
  93.     <option value="1976">1976</option>
  94.     <option value="1975">1975</option>
  95.     <option value="1974">1974</option>
  96.     <option value="1973">1973</option>
  97.     <option value="1972">1972</option>
  98.     <option value="1971">1971</option>
  99.     <option value="1970">1970</option>
  100.     <option value="1969">1969</option>
  101.     <option value="1968">1968</option>
  102.     <option value="1967">1967</option>
  103.     <option value="1966">1966</option>
  104.     <option value="1965">1965</option>
  105.     <option value="1964">1964</option>
  106.     <option value="1963">1963</option>
  107.     <option value="1962">1962</option>
  108.     <option value="1961">1961</option>
  109.     <option value="1960">1960</option>
  110.     <option value="1959">1959</option>
  111.     <option value="1958">1958</option>
  112.     <option value="1957">1957</option>
  113.     <option value="1956">1956</option>
  114.     <option value="1955">1955</option>
  115.     <option value="1954">1954</option>
  116.     <option value="1953">1953</option>
  117.     <option value="1952">1952</option>
  118.     <option value="1951">1951</option>
  119.     <option value="1950">1950</option>
  120.     <option value="1949">1949</option>
  121.     <option value="1948">1948</option>
  122.     <option value="1947">1947</option>
  123.     <option value="1946">1946</option>
  124.     <option value="1945">1945</option>
  125.     <option value="1944">1944</option>
  126.     <option value="1943">1943</option>
  127.     <option value="1942">1942</option>
  128.     <option value="1941">1941</option>
  129.     <option value="1940">1940</option>
  130.     <option value="1939">1939</option>
  131.     <option value="1938">1938</option>
  132.     <option value="1937">1937</option>
  133.     <option value="1936">1936</option>
  134.     <option value="1935">1935</option>
  135.     <option value="1934">1934</option>
  136.     <option value="1933">1933</option>
  137.     <option value="1932">1932</option>
  138.     <option value="1931">1931</option>
  139.     <option value="1930">1930</option>
  140.     <option value="1929">1929</option>
  141.     <option value="1928">1928</option>
  142.     <option value="1927">1927</option>
  143.     <option value="1926">1926</option>
  144.     <option value="1925">1925</option>
  145.     <option value="1924">1924</option>
  146.     <option value="1923">1923</option>
  147.     <option value="1922">1922</option>
  148.     <option value="1921">1921</option>
  149.     <option value="1920">1920</option>
  150.     <option value="1919">1919</option>
  151.     <option value="1918">1918</option>
  152.     <option value="1917">1917</option>
  153.     <option value="1916">1916</option>
  154.     <option value="1915">1915</option>
  155.     <option value="1914">1914</option>
  156.     <option value="1913">1913</option>
  157.     <option value="1912">1912</option>
  158.     <option value="1911">1911</option>
  159.     <option value="1910">1910</option>
  160.     <option value="1909">1909</option>
  161.     <option value="1908">1908</option>
  162.     <option value="1907">1907</option>
  163.     <option value="1906">1906</option>
  164.     <option value="1905">1905</option>
  165.     <option value="1904">1904</option>
  166.     <option value="1903">1903</option>
  167.     <option value="1902">1902</option>
  168.     <option value="1901">1901</option>
  169.     <option value="1900">1900</option>
  170. </select>
  171. </td>
  172.      </tr>
  173.      <tr>
  174.        <td>Address:</td>
  175.        <td><input type="text" name="Address"></td>
  176.      </tr>
  177.      <tr>
  178.        <td>Address 2: </td>
  179.        <td><input type="text" name="Address2"></td>
  180.      </tr>
  181.      <tr>
  182.        <td>Parish:</td>
  183.        <td><input type="text" name="Parish"></td>
  184.      </tr>
  185.      <tr>
  186.        <td>Post Code: </td>
  187.        <td><input type="text" name="PostCode"></td>
  188.      </tr>
  189.      <tr>
  190.        <td>Telephone:</td>
  191.        <td><input type="text" name="Telephone"></td>
  192.      </tr>
  193.      <tr>
  194.        <td>Email: (*) </td>
  195.        <td><input type="text" name="EmailFrom"></td>
  196.      </tr>
  197.      <tr>
  198.        <td rowspan="2">Preferred Insurance: (*) </td>
  199.        <td><p>
  200.           <input name="PreferredInsurance" type="checkbox" value="Argus">
  201.           Argus 
  202.           <input type="checkbox" name="PreferredInsurance" value="BFandM">
  203.          BF&amp;M 
  204.          <input type="checkbox" name="PreferredInsurance" value="Colonial">
  205.          Colonial </p>
  206.        </td>
  207.      </tr>
  208.      <tr>
  209.        <td><input type="checkbox" name="PreferredInsurance" value="Freisenbruch &amp; Meyer ">
  210. Freisenbruch &amp; Meyer
  211. <input type="checkbox" name="PreferredInsurance" value="Other">
  212. Other </td>
  213.      </tr>
  214.      <tr>
  215.        <td>If Other, please specify: (*) </td>
  216.        <td><input type="text" name="IfOtherPleaseSpecify"></td>
  217.      </tr>
  218.      <tr>
  219.        <td>Current License Plate Number: (*)</td>
  220.        <td><input type="text" name="CurrentLicensePlateNumber"></td>
  221.      </tr>
  222.      <tr>
  223.        <td>Vehicle:</td>
  224.        <td><input type="url" name="Vehicle" style="width: 250px" value="http://www.peugeot.bm/107/default.asp"></td>
  225.      </tr>
  226.      <tr>
  227.        <td><input type="reset" name="Reset" value="Reset">       
  228.        <input name="submit" type="submit" onClick="MM_validateForm('Name','','R','EmailFrom','','R','CurrentLicensePlateNumber','','R');return document.MM_returnValue" value="Submit"></td>
  229.        <td>&nbsp;</td>
  230.      </tr>
  231.    </table>
  232.    <p>&nbsp;</p>
Oct 28 '10 #1
1 2008
gits
5,390 Expert Mod 4TB
that looks like a dreamweaver-script, or any other macromedia-generated script? it is quite hard to say what fails ... does Firefox's error-console or firebug tell about any error that occurs? it could be that the MM_findObj() fails or any validation code ...

and I strongly doubt that someone here really likes that MM-generated scripts - at least i would always suggest to not use them - most of them is just a mess to debug and fix. do you use the latest version of the generator-software? if not then first check for updates etc. ... since it is a commercial app that should be supported if there are bugs.
Oct 30 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: RSB | last post by:
Hi Every one Need some help to Validate the Date i have in the Form. ALso how to Convert the Date Data i read from table to yyyy/MMM/dd format. Thanks RSB
1
by: jayparaiso | last post by:
Hi! How to validate check box and drop down menu in one form?
0
by: biap | last post by:
I'm working on a client/server application.The client is a window Form and the server is a Console Application. But now I also need a form in the server application,which I added. but if I call the...
16
by: browntown | last post by:
so I have this application I'm nearly finished with. The only thing the client has requested is the ability to submit the form by pressing "enter". I didn't think this would be a huge pain in the...
1
by: rija | last post by:
Hi folks, I need help regarding date and time comparison in PHP and MySQL My website is hosted in the USA (GMT - 8) And It is managed in Madagascar (GMT + 3) Want to consider DATE in Madagascar...
3
by: samuelberthelot | last post by:
Hello, I would like to validate a date in a textbox on the onChange event. The date must be in the format 01/01/2007 I would like to use a regular expression to validate it but I'm not very...
1
by: lyealain | last post by:
how do i validate the date inserted from textbox to check whether that is follow the date requirement... i wrote this... if not (isnumeric(inserteddate)) then if isdate(inserteddate) then ...
2
by: Mick Walker | last post by:
Hi, I have a problem that I have been trying to figure for a couple of days, and am wondering if anyone out there would be so kind as to give me a solution. (Deadline time) I am trying to...
2
by: tahseenm | last post by:
I would like to know the easy way to make my date field to pop up calendar to select my dates in a form date field. Thanks and let me know soon.
9
by: dragon52 | last post by:
Hi all, I want to validate on the client side and I have the following php code (tbxBirthDate is the text box, ie name="tbxBirthDate") with(window.document.enrollForm) { . ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.