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

Onsubmit form validation will not run..

57
Hi all

I have a form (see below), which for some reason has decided to stop functioning all together. It just does not call up the function. It is called up in the opening <form> tag but fails.... Any ideas???

[HTML]<html>
<head><title>New Details</title>

</head>
<center>
<H2><IMG SRC="$(path)smlogo.gif"><br>
Form No EN$(FORMNO)
<br>
</h2>
[/html]
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. <!--
  3. //Script to check form for mandatory fields and for flexi details
  4. function formCheck(formobj){
  5.     // Enter name of mandatory fields
  6.     var fieldRequired = Array("Manager_Name", "Manager_Email", "Date_Required", "Surname", "Forename", "Tel_No", "Job_Title", "Job_TitleW", "Section", "SectionW");
  7.     // Enter field description to appear in the dialog box
  8.     var fieldDescription = Array("Managers Name", "Managers Email", "Date Required", "Surname", "Forename", "Telephone Number", "Job Title", "Welsh Job Title", "Section", "Welsh Section");
  9.     // dialog message
  10.     var alertMsg = "Please complete the following fields:\n";
  11.  
  12.     var l_Msg = alertMsg.length;
  13.  
  14.     for (var i = 0; i < fieldRequired.length; i++){
  15.         var obj = formobj.elements[fieldRequired[i]];
  16.         if (obj){
  17.             switch(obj.type){
  18.             case "select-one":
  19.                 if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
  20.                     alertMsg += " - " + fieldDescription[i] + "\n";
  21.                 }
  22.                 break;
  23.             case "select-multiple":
  24.                 if (obj.selectedIndex == -1){
  25.                     alertMsg += " - " + fieldDescription[i] + "\n";
  26.                 }
  27.                 break;
  28.             case "text":
  29.             case "textarea":
  30.                 if (obj.value == "" || obj.value == null){
  31.                     alertMsg += " - " + fieldDescription[i] + "\n";
  32.                 }
  33.                 break;
  34.             default:
  35.             }
  36.             if (obj.type == undefined){
  37.                 var blnchecked = false;
  38.                 for (var j = 0; j < obj.length; j++){
  39.                     if (obj[j].checked){
  40.                         blnchecked = true;
  41.                     }
  42.                 }
  43.                 if (!blnchecked){
  44.                     alertMsg += " - " + fieldDescription[i] + "\n";
  45.                 }
  46.             }
  47.         }
  48.     }
  49.  
  50.     if (alertMsg.length == l_Msg){
  51.         toggle_form();
  52.     }else{
  53.         alert(alertMsg);
  54.         return false;
  55.     }
  56.  
  57.     var flexi = document.FrontPage_Form1.Flexi_Time;
  58.     var flexidate = document.FrontPage_Form1.Flexi_Start_Date
  59.     var fleximanager = document.FrontPage_Form1.Flexi_Manager
  60.  
  61.     if (flexi.value="Yes" && flexidate.value="") {alert("Please enter Flexi Start Date")}
  62.     flexidate.focus();
  63.     return false;
  64.     else {return true;}
  65.  
  66.     if (flexi.value="Yes" && fleximanager.value="") {alert("Please enter flexi Supervisor ID")}
  67.     fleximanager.focus();
  68.     return false;
  69.     else {return true;}
  70.  
  71.  
  72. }
  73.  
  74. // -->
  75. </script>
  76. <script> 
  77.             function toggle_display() { 
  78.                 var form   = document.getElementById('hidesubmit'); 
  79.                 var submit = document.getElementById('submit_group'); 
  80.                 ((form.checked)? submit.style.display='block': submit.style.display='none');
  81.                 }
  82. </script>
  83.  
  84.  
  85. <script> 
  86.             function toggle_form() { 
  87.                 var form   = document.getElementById('e_form'); 
  88.                 var thanks = document.getElementById('THANKS'); 
  89.                 form.style.display ='none'; 
  90.                 thanks.style.display='block'; 
  91.             } 
  92. </script>
  93.  
  94. <script>
  95. // Script to check Email address is valid
  96.  
  97. function emailvalidation(entered, alertbox)
  98. {
  99.  
  100. with (entered)
  101. {
  102. apos=value.indexOf("@"); 
  103. dotpos=value.lastIndexOf(".");
  104. lastpos=value.length-1;
  105. if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
  106. {if (alertbox) {alert(alertbox);} return false;}
  107. else {return true;}
  108. }
  109. }
  110. </script>
  111.  
  112.  
  113.  
  114.  
  115.  
[html]
</head>


<body>

<div id="THANKS" style="display:none;">
&nbsp;<table border="0" width="72%" id="table25">
<tr>
<td align="center" width="887">
<img border="0" src="_borders/conwyLogo.gif" width="97" height="64" align="right"></td>
</tr>
<tr>
<td align="center" width="887"><b>Thank you for submitting an e-Enrolment Form.</b></td>

</tr>
<tr><td align="center" width="887">Use the form number (above) if you need to chase the progress of the enrolent</td>
</tr>
<tr>&nbsp;
</tr>
<tr>
<td align="center" width="887">Please allow 3 full working days before chasing progress.</td>
</tr>

</tr>
<tr>
<td align="center" width="887">You may now
<a href="#" onClick="window.close();">Close</a> this window.</td>
</tr>
</table>
</div>

<form method="post" action="mailto:__MUNGED__?subject=test enctype="text/plain" subject="New User" name="FrontPage_Form1" onsubmit="return formCheck(this);" id="e_form" language="JavaScript" style="display:block;"> </div>
<table width="752">
<tr>
<td width="79%">
<p align="center">&nbsp;</td>
</tr>
</table>
<table border="0" width="72%" id="table2" bgcolor="#FFFFCC">
<tr>
<td align="right" width="37%">
<p align="left"><font color="#0000FF"><b>Step 1 - Line
Managers Details.</b></font></td>
<td align="left" width="62%">
&nbsp;</td>
</tr>
<tr>
<td align="right" colspan="2">
<p align="left"><font size="2"><b>This should be the details
of the line manager requesting this e-Enrolment.</b></font></td>
</tr>
<tr>
<td align="right" width="37%">
<font size="2">Name:</font></td>
<td align="left" width="62%">
&nbsp;<input type="text" name="Manager_Name" size="36" tabindex="1"><font color="#FF0000">*</font></td>
</tr>
<tr>
<td align="right" width="37%">
<font size="2">Job Title:</font></td>
<td align="left" width="62%">
&nbsp;<input type="text" name="Manager_Job_Title" size="36" tabindex="2"></td>
</tr>
<tr>
<td align="right" width="37%">
<font size="2">Email Address:</font></td>
<td align="left" width="62%">
&nbsp;<input type="text" name="Manager_Email" size="36" tabindex="3" onChange="emailvalidation(this, 'Email address is invalid');"><font color="#FF0000">*</font></td>
</tr>

<input type="radio" name="Flexi_Time" value="Yes"></font></td>
<td align="center" width="19%">
&nbsp;</td>
</tr>

<tr>
<td width="95%" colspan="5">
<p align="center"><b><font size="2">Flexi Attendance Details</font></b></td>
</tr>

<tr>
<td width="45%" colspan="2">
<p align="center"><font size="2">Start recording from (dd/mm/yy)</font></td>
<td width="53%" align="center" colspan="3">
<font size="2">User ID of Person Monitoring Flexi</font></td>
</tr>

<tr>
<td width="45%" colspan="2">
<p align="center">
<input type="text" name="Flexi_Start_Date" size="10" maxlength="8"></td>
<td width="53%" align="center" colspan="3">
<input type="text" name="Flexi_Manager" size="10" maxlength="8" style="text-transform: uppercase"></td>
</tr>
</table>
<p>


<div id="submit_group" style="display:none;">
<table border="0" width="70%" id="table22" bgcolor="#CCFFFF">
<tr>
<td>
<p align="center"><font size="2">You may now click the SUBMIT button to
submit your e-Enrolment.</font><p align="center"><font size="2">When you click SUBMIT a screen will pop up indicating a program is sending an Email on your behalf.<br>
<b>You must click YES to submit the form.</b></font></td>
</tr>
</table>
<p>


<input type="Submit" value="Submit!">
<input type="reset" value="Clear Form">
</p>
</div>


<textarea rows="7" name="Authority" cols="30" style="width:753; font-weight:bold; height:116; font-family:Arial" wrap=virtual>ACCESS AUTHORISATION
I certify that the above named user (being an Employee or Agency Worker) has signed the relevant Induction Programme Form to confirm that they have been issued with, read and understood the Corporate Information Security Policy and, where applicable, the Email and Internet Policies

I understand that failure to do so could result in disciplinary action.
</textarea><br>
<input type="checkbox" name="agreecheck" id="hidesubmit" value="Agreed" onClick="toggle_display();"/>
By placing a check in the box you are agreeing to the above Access Authorisation Statement.</font></b></p>

<input type="hidden" name="EOR" value="">
</form>

<p>&nbsp;</p>
<p>&nbsp;</p>

</body>

</html>

</table>
</table>[/HTML]

Basically, the form should validate the fields are filed out correctly then unhide the submit button, when the submit button is pressed it hides the form and just displays a thank you.
It shouls aldo check the 'Flexi' radio button which if is yes then checks the next two fields are filled out.
Hope all that makes sense...
Any help would be grreatly appreciated..

One question.... what is the difference between putting the script in <!-- and --> or just inside the <script> tags??
Sep 3 '07 #1
5 2519
acoder
16,027 Expert Mod 8TB
Moved from the Articles section. Please do not post questions in the Articles section.
Sep 3 '07 #2
acoder
16,027 Expert Mod 8TB
Do you get any errors? If so, what are they?
Sep 3 '07 #3
plumba
57
Do you get any errors? If so, what are they?
I get a syntax error on line 61 & 66.
Sep 3 '07 #4
acoder
16,027 Expert Mod 8TB
I get a syntax error on line 61 & 66.
Your closing brackets are in the wrong place. Move it so that it's next to the else:
Expand|Select|Wrap|Line Numbers
  1. if (flexi.value="Yes" && flexidate.value="") {alert("Please enter Flexi Start Date")
  2.     flexidate.focus();
  3.     return false;
  4.     } else {return true;}
Sep 3 '07 #5
markrawlingson
346 Expert 100+
Thought i'd point this line out too..

Expand|Select|Wrap|Line Numbers
  1. action="mailto:__MUNGED__?subject=test 
  2.  
From your form tag, there's no end quote - it could cause headaches down the road for you.
Sep 3 '07 #6

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

Similar topics

3
by: Varun | last post by:
Hi There, I have a form("myRequest.asp") and the values from it are retrieved into the page ("output_Print.asp") on which I have two buttons('Save As Complete' and 'Save As Incomplete'). When the...
4
by: Stuart Wexler | last post by:
Hi, I have a form with onSubmit embedded in the <form> tag. The form is submitted programatically through javascript . While the form submits fine, nothing I'm doing seems to get it to...
4
by: Bruce Duncan | last post by:
I just noticed that if I use a "submit" button the "onSubmit" function call will be invoked. But if I use a button to call some other javascript and at the end of that javascrip I do something...
3
by: n3mtkj3mzsir0cy | last post by:
I have created web pages that do client-side form validation using the onclick directive. E.g., <form action=other_page.cgi method=post> Enter your age: <input name=age> <input type="submit"...
4
by: usl2222 | last post by:
Hi folks, I appreciate any assistance in the following problem: I have a form with a bunch of dynamic controls on it. All the controls are dynamically generated on a server, including all...
1
by: graphicsxp | last post by:
Hi, I have a few ImageButton controls on my form. One of them is the save one, on which I want the form to be submited. Other imageButtons trigger a postback, but they should not cause form...
8
by: M.L. | last post by:
Hello. I created a form using JS validation with the form tag as follows: <form name="form1" action="dynaform.php" method="post" onsubmit="return pvg_sub();"> The js validation script sends...
3
by: Olivia Towery | last post by:
I cannot figure out how to complete two script validations onsubmit. Only the first one listed runs. If anyone knows how to do this, please help. -- Olivia Towery
2
scubak1w1
by: scubak1w1 | last post by:
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.,...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.