473,395 Members | 1,583 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,395 software developers and data experts.

FORM: 'onsubmit' js validation not working when enctype="multipart/form-data"

scubak1w1
['moved' from HTML/CSS board, as suggested, thanks...]

Hello,

I am building a form that collects some data about a file and throws it into a PosgreSQL database and also allows the user to upload and process the file using PHP's $_FILES...

i.e., <input type="file" name="file" id="file" size="50"/>

Action is a PHP_SELF, method is POST, check with array_key_exists, etc... anyway..... :-)

The form works just fine if all of the data is entered correctly...

However, the 'onsubmit' js validation is not 'triggered' when the form's enctype="multipart/form-data" ??

Help! TIA! <smile>

Aside:

- once I get it working, any validation suggestions for the file upload part of the form as I can't check the $_FILES criteria prior to the submit of course

- I previously had it working via two forms - upload, check $_FILES, AJAX to turn on the submit for the details form, details entered, submit, working as desired - but only in IE! (in non-IE browsers, the submit button for the details part of the 2nd form was turned on correctly by AJAX but simply 'ignored' when clicked...)

Cheers!:
GREG...
Mar 13 '09 #1
5 7737
acoder
16,027 Expert Mod 8TB
The onsubmit should work. Post your code.
Mar 13 '09 #2
Of course, thank you:

(i) I put the validation javascript at the bottom, even though it is in the <head> - and may be you don't need it, as it it not getting there anyway
(ii) I gave you the lot, even though most is not relevant of course - apart from the PHP to process the form (as this is working)
(iii) the page is a *.php, necessarily
(iv) look for "DRAFT @ ..." to see which bits I am still working on (not relevant to this issue)
(v) I am not used to the formatting commands in the forum, so apologies in advance if it is a bot off kilter!
(vi) looking at it further, is it related the form tags are not totally within the table tags? (or vica versa)

--------------
Expand|Select|Wrap|Line Numbers
  1.  
  2. <form action="<?php print $_SERVER['PHP_SELF']; ?>" method="post" name="add_new_module_details" enctype="multipart/form-data" onsubmit="return validate_module_details_add_form">
  3.  
  4.                  <input type="hidden" name="_add_new_module_details" value="1" />
  5.  
  6.                <table align="center" cellpadding="10" width="95%" style="font-size:10px">
  7.  
  8.                    <tr style="font-weight:bold; font-size:24px; color:blue">
  9.                         <td align="center" colspan="2">
  10.                           <!-- DRAFT @ 03/12/09 - delete me --><h2 style="color:red">UNDER CONSTRUCTION</h2>
  11.                            Add The New Module File &amp; Details
  12.                      </td>
  13.                     </tr>
  14.  
  15.  
  16.                    <tr>
  17.                         <td colspan="2">
  18.                            <hr /> <!-- spacer -->
  19.                         </td>
  20.                     </tr>
  21.  
  22.  
  23.                    <tr valign="top">
  24.  
  25.                        <td align="left" width="50%">
  26.                                 <strong style="font-size:12px">
  27.                             Module ID:
  28.                         </strong>
  29.                         <br />
  30.                                  <input type="text" name="new_module_id" size="6" maxlength="6" />
  31.                         <br />
  32.                              <em style="color:gray">
  33.                             (&le; 6 letters, numbers &amp; underscores,
  34.                              <br />
  35.                              using a proscribed 'pattern.')
  36.                       </em>
  37.                      </td>
  38.  
  39.                       <td align="right" width="50%" rowspan="2">
  40.                                    <strong style="font-size:12px">
  41.                                Module Title:
  42.                          </strong>
  43.                       <textarea name="new_module_title" cols="25" rows="7" style="margin-top:-1px; margin-bottom:-1px"></textarea>
  44.                             </td>
  45.  
  46.                     </tr>
  47.  
  48.  
  49.                   <tr valign="top">
  50.                          <td align="left">
  51.                                 <strong style="font-size:12px">
  52.                             File Name:
  53.                         </strong>
  54.                     <input type="text" name="new_module_filename" size="30" maxlength="50"/>
  55.                         <br />
  56.                           <em style="color:gray">
  57.                                 (&le;50 letters, numbers and underscores only;
  58.                                 <br />
  59.                             no file extension)                         </em>
  60.                      </td>
  61.                   </tr>
  62.  
  63.                    <tr valign="top">
  64.                       <td align="left">
  65.                              <strong style="font-size:12px">
  66.                             File Extension:
  67.                         </strong>
  68.                         <br />
  69.                         <select name="new_module_file_extension">
  70.                             <option value="not_yet_selected" selected="selected">[select]</option>
  71.                                     <?php
  72.                                         foreach($ary_possible_file_extensions as $ary_query_row)
  73.                                             {
  74.                                                 if($ary_query_row['file_extension'] != $ary_selected_module_details['file_extension'])
  75.                                                     {
  76.                                                         print "<option value=\"".$ary_query_row['file_extension']."\">".$ary_query_row['file_extension']."</option>";
  77.                                                     }
  78.                                                     else
  79.                                                     {
  80.                                                         print "<option value=\"".$ary_query_row['file_extension']."\" selected=\"selected\">".$ary_query_row['file_extension']."</option>";
  81.                                                     };
  82.                                             };
  83.                                     ?>
  84.                             </select>
  85.                          <br />
  86.                          <em style="color:gray">
  87.                                  (see fuller descriptions at the base of the page)                        </em>                     </td>
  88.                       <td align="right">
  89.                                 <strong style="font-size:12px">
  90.                             Module Group:
  91.                         </strong>
  92.                         <br />
  93.                         <select name="new_module_group">
  94.                              <option value="not_yet_selected" selected="selected">[select]</option>
  95.                                     <?php
  96.                                         foreach($ary_possible_module_groups as $ary_query_row)
  97.                                             {
  98.                                                 print "<option value=\"".$ary_query_row['module_group']."\">".$ary_query_row['module_group']."</option>";
  99.                                             };
  100.                                     ?>
  101.                          </select>
  102.                         <br />
  103.                          <em style="color:gray">
  104.                                 (see fuller descriptions at the base of the page)                         </em>                     </td>
  105.                    </tr>
  106.  
  107.                    <tr valign="top">
  108.                       <td align="left">
  109.                                 <strong style="font-size:12px">
  110.                             Module Contact:
  111.                         </strong>
  112.                         <br />
  113.                         <select name="new_module_contact_id">
  114.                                     <option value="not_yet_selected" selected="selected">[select]</option>
  115.                                     <?php
  116.                                         foreach($ary_possible_module_contacts as $ary_query_row)
  117.                                             {
  118.                                                 print "<option value=\"".$ary_query_row['contact_id']."\">".$ary_query_row['fname']." ".$ary_query_row['lname']." [".$ary_query_row['contact_id']."]</option>";
  119.                                             };
  120.                                     ?>
  121.                          </select>
  122.                         <br />
  123.                          <em style="color:gray">
  124.                                  (employee name, with [eID])                        </em>                     </td>
  125.  
  126.                      <td align="right">
  127.                                 <strong style="font-size:12px">
  128.                               Date Created:
  129.                         </strong>
  130.                         <br />
  131.                         <input type="text" name="new_module_date_created" size="10" style="text-align:right" maxlength="10" />
  132.                          <br />
  133.                         <em style="color:gray">
  134.                                 (format is mm/dd/yy)
  135.                         </em>
  136.                      </td>
  137.                    </tr>
  138.  
  139.                   <tr valign="top">
  140.                       <td align="left">
  141.                                 <strong style="font-size:12px">
  142.                             Est. Completion Time (mins.):
  143.                         </strong>
  144.                           <br />
  145.                          <input type="text" name="new_module_reasonable_completion_minutes" size="3" maxlength="3" />
  146.                          </td>
  147.  
  148.                      <td align="right">
  149.                                 <strong style="font-size:12px">
  150.                             Current / Active?:
  151.                         </strong>
  152.                          <br />
  153.                               <img src="images/icon_checkbox_false1.gif" alt="[checked box icon]" title="NOT 'clickable'" />
  154.                          <br />
  155.                          <em style="color:gray">
  156.                              (NOTE: the module will be 'inactive' until the site manager can 'process' the uploaded file/s)
  157.                          </em>
  158.                             </td>
  159.                   </tr>
  160.  
  161.                   <tr valign="top">
  162.                        <td align="left">
  163.                             <strong style="font-size:12px">
  164.                             Limited Access?:
  165.                         </strong>
  166.                         <br />
  167.                         <input type="checkbox" name="new_module_limited_access" value="true" />
  168.                         <br />
  169.                           <em style="color:gray">
  170.                                  (i.e., this module's access is limited to 'certain' employees)
  171.                           </em>
  172.                      </td>
  173.                      <td align="right">
  174.                             <strong style="font-size:12px">
  175.                             Test Required?:                        </strong>
  176.                         <br />
  177.                         <input type="checkbox" name="new_module_test_required" value="true" />
  178.                    </td>
  179.                   </tr>
  180.  
  181.                   <tr valign="top">
  182.                       <td align="left">
  183.                             <strong style="font-size:12px">
  184.                             Number Test Questions?:
  185.                         </strong>
  186.                         <br />
  187.                         <input type="text" name="new_module_number_test_questions" size="2" maxlength="2" />
  188.                         <br />
  189.                         <em style="color:gray">
  190.                                 (if applicable)
  191.                         </em>
  192.                      </td>
  193.  
  194.                      <td align="right">
  195.                          <strong style="font-size:12px">
  196.                             Open Book Test?:
  197.                         </strong>
  198.                         <br />
  199.                         <input type="checkbox" name="new_module_open_book_test" value="true" />
  200.                            <br />
  201.                         <em style="color:gray">
  202.                                 (if applicable)
  203.                          </em>
  204.                      </td>
  205.                   </tr>
  206.  
  207.                   <tr valign="top">
  208.                        <td colspan="2" align="left">
  209.                                 <strong style="font-size:12px">
  210.                             Module Comment:
  211.                         </strong>
  212.                         <textarea name="new_module_comment" cols="60" rows="5" style="margin-top:-1px; margin-bottom:-1px"></textarea>
  213.                         <br />
  214.                                 <em style="color:gray">
  215.                                 (Note: the date &amp; time and the logged-on user that added these module details will be appended to these comments 'automagically')
  216.                          </em>
  217.                      </td>
  218.     </tr>
  219.  
  220.  
  221.                   <tr valign="top">
  222.                          <td colspan="2" align="center">
  223.                                 <strong style="font-size:12px">
  224.                                 Select The <strong>*.ZIP</strong> File For Upload:
  225.                         </strong>
  226.                                 <br />
  227.                     <input type="file" name="file" id="file" size="50"/>
  228.                     </td>
  229.                   </tr>
  230.  
  231.  
  232.                   <tr valign="top">
  233.                       <td align="left">
  234.                          <img src="images/icon_reset7.gif" alt="Click To Reset" title="Reset The Pulldowns, etc" onclick="return funResetAddModuleDetailsForm()" style="cursor:pointer" />
  235.                          </td>
  236.                      <td align="right">
  237.                          <input
  238.                                type = "image"
  239.                               value = "Upload"
  240.                               name = "submit_add_new_module_details"
  241.                               class = "toggleopacity"
  242.                               src = "images/icon_submit4.gif"
  243.                               title = "Upload New Module Presentation File"
  244.                            />
  245.                      </td>
  246.                   </tr>
  247.  
  248.               </form>
  249.  
  250.  
--------------

Expand|Select|Wrap|Line Numbers
  1. //validate the module detail edits form contents
  2.         function validate_module_details_add_form()
  3.             {
  4.  
  5.                 //DRAFT @ 03/12/09 - delete these lines 
  6.                 alert('Form validation triggered...');
  7.  
  8.                 //check to see if MODULE ID text field was left blank
  9.                 if(document.add_new_module_details.new_module_id.value.length == 0)
  10.                     {
  11.                    alert("Please enter some text for the new MODULE ID...");
  12.                   document.add_new_module_details.new_module_id.focus(); //set the focus to this element, so the user can correct the entry
  13.                   return false;
  14.                     };
  15.  
  16.                 //check to see that the MODULE ID is numbers, letters and underscores (note - 6 characters or less 'requirement' is via form entry field size setting)
  17.                 var AllowedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_";
  18.                 for(var i = 0; i < document.add_new_module_details.new_module_id.value.length; i++)
  19.                     {
  20.                           if (AllowedChars.indexOf(document.add_new_module_details.new_module_id.value.charAt(i)) == -1) 
  21.                               {
  22.                                   alert("For the new MODULE ID, only use:\n\n - letters\n\n - numbers\n\n - underscores");
  23.                                 document.add_new_module_details.new_module_id.focus(); //set the focus to this element, so the user can 'correct' the entry
  24.                                   return false;
  25.                               };
  26.                      };
  27.  
  28.                 //check to see that the MODULE ID is UNIQUE
  29.                 var IDAlreadyUsed = false;
  30.                 <?php
  31.                     foreach($ary_existing_module_details_sum as $ary_row)
  32.                         {
  33.                             ?>
  34.                                 if(document.add_new_module_details.new_module_id.value == '<?php print $ary_row['module_id']; ?>')
  35.                                     {
  36.                                         IDAlreadyUsed = true;
  37.                                     };
  38.                             <?php
  39.                         };
  40.                 ?>
  41.                 if(IDAlreadyUsed == true)
  42.                     {
  43.                    alert("     MODULE ID\nis already in use...\n\n     Please adjust...");
  44.                   document.add_new_module_details.new_module_id.focus(); //set the focus to this element, so the user can correct the entry
  45.                   return false;
  46.                     };
  47.  
  48.  
  49.                 //check to see if MODULE TITLE text field was left blank
  50.                 if(document.add_new_module_details.new_module_title.value.length == 0)
  51.                     {
  52.                    alert("Please enter some text for the new MODULE TITLE...");
  53.                   document.add_new_module_details.new_module_title.focus(); //set the focus to this element, so the user can correct the entry
  54.                   return false;
  55.                     };
  56.  
  57.                 //check to see that the MODULE TITLE is UNIQUE
  58.                 var TitleAlreadyUsed = false;
  59.                 <?php
  60.                     foreach($ary_existing_module_details_sum as $ary_row)
  61.                         {
  62.                             ?>
  63.                                 if(document.add_new_module_details.new_module_title.value == '<?php print $ary_row['module_title']; ?>')
  64.                                     {
  65.                                         TitleAlreadyUsed = true;
  66.                                     };
  67.                             <?php
  68.                         };
  69.                 ?>
  70.                 if(TitleAlreadyUsed == true)
  71.                     {
  72.                    alert("     TITLE\nis already in use...\n\n     Please adjust...");
  73.                   document.add_new_module_details.new_module_title.focus(); //set the focus to this element, so the user can correct the entry
  74.                   return false;
  75.                     };
  76.  
  77.                 //check to see if new module's FILE NAME field was left blank
  78.                 if(document.add_new_module_details.new_module_filename.value.length == 0)
  79.                     {
  80.                    alert("Please enter a some text for the new module's FILE NAME...");
  81.                   document.add_new_module_details.new_module_filename.focus(); //set the focus to this element, so the user can correct the entry
  82.                   return false;
  83.                     };
  84.  
  85.                 //check to see if new module's FILE NAME field seemingly includes a file extension (assuming that it is unless shown otherwise) - NOTE THAT would be 'caught' as the peroid would lick back in the form validiation as a 'illegal character', but this way it is easier for the user to comprehend the issue and edit
  86.                 if((document.add_new_module_details.new_module_filename.value).substr(document.add_new_module_details.new_module_filename.value.length-4,1) == '.')
  87.                     {
  88.                    alert("It appears that you have added a FILE EXTENSION to the new module's FILE NAME...\n\nPlease delete before resubmitting...\n\n(use the extension 'pull-down' to record this info...)");
  89.                   document.add_new_module_details.new_module_filename.focus(); //set the focus to this element, so the user can 'correct' the entry
  90.                   return false;
  91.                     };
  92.  
  93.                 //check to see that the FILE NAME is numbers, letters and underscores (note - 50 characters or less 'requirement' is via form entry field size setting)
  94.                 var AllowedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_";
  95.                 for(var i = 0; i < document.add_new_module_details.new_module_filename.value.length; i++)
  96.                     {
  97.                           if (AllowedChars.indexOf(document.add_new_module_details.new_module_filename.value.charAt(i)) == -1) 
  98.                               {
  99.                                   alert("For the new FILE NAME, only use:\n\n - letters\n\n - numbers\n\n - underscores");
  100.                                 document.add_new_module_details.new_module_filename.focus(); //set the focus to this element, so the user can correct the entry
  101.                                   return false;
  102.                               };
  103.                      };
  104.  
  105.                 //check to see that the FILE NAME is UNIQUE
  106.                 var FileNameAlreadyUsed = false;
  107.                 <?php
  108.                     foreach($ary_existing_module_details_sum as $ary_row)
  109.                         {
  110.                             ?>
  111.                                 if(document.add_new_module_details.new_module_filename.value == '<?php print $ary_row['file_name']; ?>')
  112.                                     {
  113.                                         FileNameAlreadyUsed = true;
  114.                                     };
  115.                             <?php
  116.                         };
  117.                 ?>
  118.                 if(FileNameAlreadyUsed == true)
  119.                     {
  120.                    alert("     FILE NAME\nis already in use...\n\n     Please adjust...");
  121.                   document.add_new_module_details.new_module_filename.focus(); //set the focus to this element, so the user can correct the entry
  122.                   return false;
  123.                     };
  124.  
  125.                 //check to make sure the user has selected a FILE EXTENSION from the pulldown
  126.                 if(document.add_new_module_details.new_module_file_extension.value == 'not_yet_selected')
  127.                     {
  128.                      alert("Please select the new module's FILE EXTENSION from the appropiate form 'pull-down'...");
  129.                     document.add_new_module_details.new_module_file_extension.focus(); //set the focus to this element, so the user can correct the entry
  130.                     return false;
  131.                     };
  132.  
  133.                 //check to make sure the user has selected a MODULE GROUP from the pulldown
  134.                 if(document.add_new_module_details.new_module_group.value == 'not_yet_selected')
  135.                     {
  136.                      alert("Please select the new module's MODULE GROUP from the appropiate form 'pull-down'...");
  137.                     document.add_new_module_details.new_module_group.focus(); //set the focus to this element, so the user can correct the entry
  138.                     return false;
  139.                     };
  140.  
  141.                 //check to make sure the user has selected a MODULE CONTACT from the pulldown
  142.                 if(document.add_new_module_details.new_module_contact_id.value == 'not_yet_selected')
  143.                     {
  144.                      alert("Please select the new module's MODULE CONTACT from the appropiate form 'pull-down'...");
  145.                     document.add_new_module_details.new_module_contact_id.focus(); //set the focus to this element, so the user can correct the entry
  146.                     return false;
  147.                     };
  148.  
  149.                 //check that the DATE CREATED field is not blank
  150.                 if(document.add_new_module_details.new_module_date_created.value.length == 0)
  151.                     {
  152.                    alert("Please enter the new module's DATE CREATED...");
  153.                   document.add_new_module_details.new_module_date_created.focus(); //set the focus to this element, so the user can correct the entry
  154.                   return false;
  155.                     };
  156.  
  157.                 //check that the DATE CREATED field is in the correct format
  158.                 if(checkValidDate(document.add_new_module_details.new_module_date_created.value) == false)
  159.                     {
  160.                    alert('The DATE CREATED is not in a valid date format...\n\nPlease adjust before resubmitting...');
  161.                         document.add_new_module_details.new_module_date_created.focus(); //set the focus to this element, so the user can 'correct' the entry
  162.                   return false;
  163.                };
  164.  
  165.                 //grab the date, add the right century, make into a js date
  166.                 var entered_date_string = document.add_new_module_details.new_module_date_created.value;
  167.                 if(((entered_date_string).substr(entered_date_string.length-3,1) == '/'))
  168.                     {
  169.                         //if the full years (i.e., 20##) are not there, add them so the js date creation works properly - with the assumption that the date is 20##
  170.                         left = entered_date_string.substr(1,entered_date_string.length-3);
  171.                         right = entered_date_string.substr(entered_date_string.length-2,2);
  172.                         if(parseInt(right) < 30)
  173.                             {
  174.                                 century = '20';
  175.                             }
  176.                             else
  177.                             {
  178.                                 century = '19';
  179.                             }
  180.                         entered_date_string_adjusted = left + century + right;
  181.                     }
  182.                     else
  183.                     {
  184.                         entered_date_string_adjusted = entered_date_string; //i.e., already has the century included
  185.                     }
  186.  
  187.                 //check that the DATE CREATED field is not in the future
  188.                 var today = new Date();
  189.  
  190.                 var entered_date_converted = new Date(entered_date_string_adjusted);
  191.                 if(entered_date_converted > today)
  192.                     {
  193.                         alert('The DATE CREATED is in the future...\n\nPlease adjust before resubmitting...');
  194.                         document.add_new_module_details.new_module_date_created.focus(); //set the focus to this element, so the user can 'correct' the entry
  195.                   return false;
  196.                     }
  197.                     else
  198.                     {
  199.                         //ensure the date on the form is this century, even though the user will not see (although the code doesn't likely need this...)
  200.                         document.add_new_module_details.new_module_date_created.value = entered_date_string_adjusted;
  201.                     };
  202.  
  203.                 //check to see if ESTIMATED COMPLETION TIME field was left blank
  204.                 if(document.add_new_module_details.new_module_reasonable_completion_minutes.value.length == 0)
  205.                     {
  206.                    alert("Please enter a numeric value for the ESTIMATED COMPLETION TIME (minutes)...");
  207.                   document.add_new_module_details.new_module_reasonable_completion_minutes.focus(); //set the focus to this element, so the user can correct the entry
  208.                   return false;
  209.                     };
  210.  
  211.                 //check to see that the ESTIMATED COMPLETION TIME is a numeric value (note - 3 characters or less 'requirement' is via form entry field size setting)
  212.                 if(!IsNonZeroInteger(document.add_new_module_details.new_module_reasonable_completion_minutes.value))
  213.                     {
  214.                         alert('The ESTIMATED COMPLETION TIME (minutes) needs to be an integer value (1 to 999)');
  215.                         document.add_new_module_details.new_module_reasonable_completion_minutes.focus(); //set the focus to this element, so the user can 'correct' the entry
  216.                         return false;
  217.                     };
  218.  
  219.                 //if the new module is indicated as 'test required', check to see the user has entered a numeric value for the number of test questions, etc
  220.                 if(document.add_new_module_details.new_module_test_required.checked == true)
  221.                     {
  222.  
  223.                         //check that the module's desired number of questions is an integer (or null)
  224.                         if(!IsNonZeroInteger(document.add_new_module_details.new_module_number_test_questions.value))
  225.                             {
  226.                                 alert('The desired NUMBER TEST QUESTIONS needs to be an integer value (1 to 99)');
  227.                                 document.add_new_module_details.new_module_number_test_questions.focus(); //set the focus to this element, so the user can 'correct' the entry
  228.                                 return false;
  229.                             };
  230.  
  231.                         //if the 'test required' is true, then confirm that a value for number of test questions has been entered
  232.                         if(document.add_new_module_details.new_module_number_test_questions.value == 0)
  233.                             {
  234.                                 alert("As the module is indicated as TEST REQUIRED,\n\nplease enter the number of desired NUMBER TEST QUESTIONS");
  235.                                 document.add_new_module_details.new_module_number_test_questions.focus(); //set the focus to this element, so the user can 'correct' the entry
  236.                                 return false;
  237.                             };
  238.  
  239.                         //if the number of desired test questions, if applicable, is over 50 then confirm with the user that this is correct
  240.                         if(parseInt(document.add_new_module_details.new_module_number_test_questions.value) > 50)
  241.                             {
  242.                                 var answer = confirm('Greater than fifty (50) desired TEST QUESTIONS was entered as the value...\n\nIs this correct?');
  243.                                 if(answer == false)
  244.                                     {
  245.                                         document.add_new_module_details.new_module_number_test_questions.focus(); //set the focus to this element, so the user can 'correct' the entry
  246.                                         return false;
  247.                                     };
  248.                             };
  249.  
  250.                     };
  251.  
  252.                 //if the new MODULE COMMENT field is empty, confirm that this is the user's intention
  253.                 if(document.add_new_module_details.new_module_comment.value.length == 0)
  254.                     {
  255.                    var answer = confirm('The new MODULE COMMENT field is blank...\n\nIs this correct?');
  256.                                 if(answer == false)
  257.                                     {
  258.                                         document.add_new_module_details.new_module_comment.focus(); //set the focus to this element, so the user can 'correct' the entry
  259.                                         return false;
  260.                                     };
  261.                     };
  262.  
  263.                 //check to make sure that the file upload field has been populated
  264.                 //DRAFT @ 03/12/09 - to write
  265.  
  266.                 //check to make sure that the file upload field has the letters ZIP on it's far right
  267.                 //DRAFT @ 03/12/09 - to write
  268.  
  269.                 //final confirmation of the desire to add the module details, copy presented in alert box
  270.                 var answer =    confirm
  271.                                     (
  272.                                         'PLEASE CONFIRM:\nThe following new MODULE DETAILS will be added ??\n\n\n'
  273.                                         + 'MODULE ID =>     ' + document.add_new_module_details.new_module_id.value + '\n\n'
  274.                                         + 'MODULE TITLE =>     ' + document.add_new_module_details.new_module_title.value + '\n\n'
  275.                                         + 'FILE NAME =>     ' + document.add_new_module_details.new_module_filename.value + '\n\n'
  276.                                         + 'FILE EXTENSION =>     ' + document.add_new_module_details.new_module_file_extension.value + '\n\n'
  277.                                         + 'MODULE GROUP =>     ' + document.add_new_module_details.new_module_group.value + '\n\n'
  278.                                         + 'MODULE CONTACT eID =>     ' + document.add_new_module_details.new_module_contact_id.value + '\n\n'
  279.                                         + 'DATE CREATED =>     ' + document.add_new_module_details.new_module_date_created.value + '\n\n'
  280.                                         + 'COMPL. TIME =>     ' + document.add_new_module_details.new_module_reasonable_completion_minutes.value + ' mins.\n\n'
  281.                                         + 'LIMITED ACCESS? =>     ' + document.add_new_module_details.new_module_limited_access.checked + '\n\n'
  282.                                         + 'TEST REQUIRED? =>     ' + document.add_new_module_details.new_module_test_required.checked + '\n\n'
  283.                                         + 'NO. QUESTIONS =>     ' + document.add_new_module_details.new_module_number_test_questions.value + '\n\n'
  284.                                         + 'OPEN BOOK? =>     ' + document.add_new_module_details.new_module_open_book_test.checked + '\n\n'
  285.                                         + 'COMMENT =>     ' + document.add_new_module_details.new_module_comment.value
  286.                                     );
  287.                 if(answer == false)
  288.                     {
  289.                         document.add_new_module_details.new_module_comment.focus(); //set the focus to this element, so the user can 'correct' the entry
  290.                         return false;
  291.                     };
  292.  
  293.                 //return the 'yay', now that the various elements have been validated as OK...
  294.                 return true;
  295.  
  296.             };
Mar 13 '09 #3
acoder
16,027 Expert Mod 8TB
You forgot the () :
Expand|Select|Wrap|Line Numbers
  1. <form ... onsubmit="return validate_module_details_add_form()">
Mar 13 '09 #4
in the vernacular, d'oh!

<embarrassed>

Cheers!
Mar 13 '09 #5
acoder
16,027 Expert Mod 8TB
Don't worry: we've all been there at some point! :)
Mar 16 '09 #6

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

Similar topics

3
by: F. Da Costa | last post by:
Hi, I was wondering *why* there is a difference between the results of the following two statements. On the suface they seem to do the same (or do they?) frm => returns void ...
13
by: Paul T. RONG | last post by:
Hello there, This is the case: the mde I made works alright on my machine, but there is a small problem when I installed it on a user's machine (His machine's OS is Windows XP Pro and it has...
12
by: Mark | last post by:
In our web.config, we have changed the first line below to look like the second: OLD: <globalization requestEncoding="utf-8" responseEncoding="utf-8" /> NEW: <globalization...
2
by: MLH | last post by:
Suppose that code running on FormB is moving the focus around on FormA to various textbox controls on FormA - Which form is the current form during this process? Is it FormA, which has the...
2
by: Mark Collard | last post by:
I've noticed that when you add a ToolTip component to a Form (or UserControl) the other controls on the form display a property in the property grid called "ToolTip on toolTip1", so you can set the...
10
by: morangolds | last post by:
Hi, I've been having a problem with C++ Windows Forms apps not "ending" when you close the form window. I've searched about this problem all over the place and most searches have lead me to...
2
by: polocar | last post by:
Hi, suppose that you have a C# form with two buttons, that are the classical "btnOk" and "btnCancel" (besides them, of course in the form there can be many other controls). When the user clicks...
2
by: boliches | last post by:
I have a form within my database which On Open (event procedure) will make many calculations and enter the results in text boxes on the page of the form (I have 2 tabs on this particular form). My...
3
by: MrCorbeaux | last post by:
My "Email a Webpage" form works find except when the end user receives the email, the URL is text only and not a hyperlink. The "Email a Page" form calls the URL from the previous page using: ...
5
by: dangt85 | last post by:
Hello, I have the following page: ... <style type="text/css"> body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.