title: javascript form validation - call two scripts on form submit
body: <p>I have a php as shown below. the page has some javascript validation. I am making use of gen_validatorv4.js found on site <a href="http://www.javascript-coder.com/html-form/javascript-form-validation.phtml#download" rel="nofollow noreferrer">found here</a>.</p>
  
  <p>This script works perfectly however cannot do a comparison validation on date time fields. To do this I got help from another stackoverflow post <a href="https://stackoverflow.com/questions/8586646/javascript-date-time-validation-yyyy-mm-dd-hhmm/8595352#8595352">found here</a>. Thanks to @RobG who gave me a working datetime comparison validation script. </p>
  
  <p>my issues is that when I add both scripts to the page only one works, disabling the other. How can I get both sets of code to be called when submitting the form?</p>
  
  <p>My complete code ii found below, thanks for the help in advance and holiday wishes to everyone!
  Ryan</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;
  
  &lt;/title&gt;
  &lt;script src="datetimepicker_css.js"&gt;&lt;/script&gt;
  &lt;script language="JavaScript" src="gen_validatorv4.js" type="text/javascript" xml:space="preserve"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  
  &lt;body&gt;
  
  &lt;?PHP
  $usernname1=$session-&gt;username;
  
  //trailers
  $trailers="SELECT vehicletypename from vehicletypes"; 
  $resulttrailer=mysql_query($trailers); 
  
  $optionstrailer=""; 
  
  while ($row=mysql_fetch_array($resulttrailer)) { 
  
      $trailer=$row["vehicletypename"]; 
      $optionsdelivery.="&lt;OPTION VALUE=\"$trailer\"&gt;".$trailer; 
  } 
  
  
  
  //Source
  $sources="SELECT sourcename from shuttlesources"; 
  $resultsources=mysql_query($sources); 
  
  $optionssources=""; 
  
  while ($row=mysql_fetch_array($resultsources)) { 
  
      $sourcename=$row["sourcename"]; 
      $optionssources.="&lt;OPTION VALUE=\"$sourcename\"&gt;".$sourcename; 
  } 
  
  
  //Destination
  $destination="SELECT destinationname from shuttledestinations"; 
  $resultdestination=mysql_query($destination); 
  
  $optionsdestination=""; 
  
  while ($row=mysql_fetch_array($resultdestination)) { 
  
      $destinationname=$row["destinationname"]; 
      $optionsdestination.="&lt;OPTION VALUE=\"$destinationname\"&gt;".$destinationname; 
  } 
  
  
  //routes
  $routesql="SELECT routename from deliveryroutes where transporttype='localpmb'"; 
  $resultdestination=mysql_query($routesql); 
  
  $optionsroute=""; 
  
  while ($row=mysql_fetch_array($resultdestination)) { 
  
      $routename=$row["routename"]; 
      $optionsroute.="&lt;OPTION VALUE=\"$routename\"&gt;".$routename; 
  } 
  
  ?&gt;
  
  
  
  &lt;form onsubmit="return checkDates(this)" name="myform" id="myform" action=captureshuttledelivery2.php method=post&gt;
  &lt;font color=red&gt;&lt;b&gt;Provide information to create shuttle delivery&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td width=150&gt;
  &lt;font color=blue&gt;TRAILER
  &lt;/td&gt;
  &lt;td width=150&gt;
  &lt;font color=blue&gt;SOURCE
  &lt;/td&gt;
  &lt;td width=150&gt;
  &lt;font color=blue&gt;WEIGHT
  &lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;tr&gt;
  
  &lt;td&gt;
      &lt;SELECT NAME=trailer style="width:140px;"&gt; 
      &lt;OPTION VALUE=0&gt;
      &lt;?=$optionsdelivery?&gt; 
      &lt;/SELECT&gt; 
  &lt;/td&gt;
  &lt;td&gt;
      &lt;SELECT NAME=source style="width:140px;"&gt; 
      &lt;OPTION VALUE=0&gt;
      &lt;?=$optionssources?&gt; 
      &lt;/SELECT&gt; 
  &lt;/td&gt;
  &lt;td&gt;
  &lt;input type=text name=weight id=weight&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td width=150&gt;
  &lt;font color=blue&gt;REF NUMBER 1&lt;/b&gt;&lt;/font&gt;
  &lt;/td&gt;
  &lt;td width=150&gt;
  &lt;font color=blue&gt;REF NUMBER 2&lt;/b&gt;&lt;/font&gt;
  &lt;/td&gt;
  &lt;td width=150&gt;
  &lt;font color=blue&gt;REF NUMBER 3&lt;/b&gt;&lt;/font&gt;
  &lt;/td&gt;
  &lt;td width=150&gt;
  &lt;font color=blue&gt;REF NUMBER 4&lt;/b&gt;&lt;/font&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;input type=text name=refnumber id=refnumber&gt;
  &lt;/td&gt;
  &lt;td&gt;
  &lt;input type=text name=refnumber2 id=refnumber2&gt;
  &lt;/td&gt;
  &lt;td&gt;
  &lt;input type=text name=refnumber3 id=refnumber3&gt;
  &lt;/td&gt;
  &lt;td&gt;
  &lt;input type=text name=refnumber4 id=refnumber4&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;
  &lt;font color=blue&gt;COLLECTION TIME
  &lt;/td&gt;
  &lt;td&gt;
  &lt;font color=blue&gt;DELIVERY TIME
  &lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;tr&gt;
  
  &lt;td&gt;
  &lt;input type="text" id="collectdatetime" name="collectdatetime"&gt;
   &lt;img src="images2/cal.gif" onclick="javascript:NewCssCal ('collectdatetime','yyyyMMdd','dropdown',true,'24')"  style="cursor:pointer"/&gt;
  &lt;/td&gt;
  &lt;td&gt;
  &lt;input type="text" id="deliverdatetime" name="deliverdatetime" &gt;
   &lt;img src="images2/cal.gif" onclick="javascript:NewCssCal ('deliverdatetime','yyyyMMdd','dropdown',true,'24')"  style="cursor:pointer"/&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td colspan=4&gt;
  &lt;font color=blue&gt;COMMENTS
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td colspan=4&gt;
  &lt;input type=text name=comments id=comments size=100 value=none&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  
  
  &lt;/table&gt;
  &lt;table&gt;
  &lt;tr&gt;&lt;td&gt;
  &lt;input type=submit name=submit id=submit value="Save Delivery"&gt;
  &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
  
  
  &lt;/form&gt;
  
  &lt;script&gt; 
  function checkDates(form) { 
    if (form.collectdatetime.value &gt;= form.deliverdatetime.value) { 
      alert('Collection time must be after deliver time'); 
      return false; 
    } 
  } 
  &lt;/script&gt; 
  &lt;script language="JavaScript" type="text/javascript" xml:space="preserve"&gt;
  //&lt;![CDATA[
  //You should create the validator only after the definition of the HTML form
    var frmvalidator  = new Validator("myform");
  
    frmvalidator.addValidation("trailer","dontselect=0","Please select a TRAILER TYPE");
  
    frmvalidator.addValidation("source","dontselect=0","Please select a SOURCE");
  
    frmvalidator.addValidation("weight","req","Please enter the LOAD WEIGHT");
    frmvalidator.addValidation("weight","numeric","Entered LOAD WEIGHT not a number");
  
    frmvalidator.addValidation("refnumber","req","Please enter at least one REFERENCE NUMBER");
    frmvalidator.addValidation("refnumber","numeric");
  
    frmvalidator.addValidation("collectdatetime","req","Please enter a COLLECTION DATE AND TIME");
  
    frmvalidator.addValidation("deliverdatetime","req","Please enter a DELIVERY DATE AND TIME");
  
  //]]&gt;
  
  &lt;/script&gt;
  
    &lt;/body&gt;
    &lt;/html&gt;
  </code></pre>