473,473 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

IE6 ignores my form validation handler

57 New Member
Ok, another problem... A bit querky this one..

My form calls an onsubmit function to check fields for completion (validation check).

Here is a breakdown version of the form:

[HTML]<html>
<script>
function toggle_display() {
var form = document.getElementById('hidesubmit');
var submit = document.getElementById('submit_group');
((form.checked)? submit.style.display='block': submit.style.display='none');
}
</script>

<script>
function toggle_form() {
var form = document.getElementById('e_form');
var thanks = document.getElementById('THANKS');
form.style.display ='none';
thanks.style.display='block';
}
</script>

<script language="JavaScript">
<!--
[/html]
Expand|Select|Wrap|Line Numbers
  1. function formCheck(formobj){
  2.     // Enter name of mandatory fields
  3.     var fieldRequired = Array("Manager_Name");
  4.     // Enter field description to appear in the dialog box
  5.     var fieldDescription = Array("First Name");
  6.     // dialog message
  7.     var alertMsg = "Please complete the following fields:\n";
  8.  
  9.     var l_Msg = alertMsg.length;
  10.  
  11.     for (var i = 0; i < fieldRequired.length; i++){
  12.         var obj = formobj.elements[fieldRequired[i]];
  13.         if (obj){
  14.             switch(obj.type){
  15.             case "select-one":
  16.                 if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
  17.                     alertMsg += " - " + fieldDescription[i] + "\n";
  18.                 }
  19.                 break;
  20.             case "select-multiple":
  21.                 if (obj.selectedIndex == -1){
  22.                     alertMsg += " - " + fieldDescription[i] + "\n";
  23.                 }
  24.                 break;
  25.             case "text":
  26.             case "textarea":
  27.                 if (obj.value == "" || obj.value == null){
  28.                     alertMsg += " - " + fieldDescription[i] + "\n";
  29.                 }
  30.                 break;
  31.             default:
  32.             }
  33.             if (obj.type == undefined){
  34.                 var blnchecked = false;
  35.                 for (var j = 0; j < obj.length; j++){
  36.                     if (obj[j].checked){
  37.                         blnchecked = true;
  38.                     }
  39.                 }
  40.                 if (!blnchecked){
  41.                     alertMsg += " - " + fieldDescription[i] + "\n";
  42.                 }
  43.             }
  44.         }
  45.     }
  46.  
  47.     if (alertMsg.length == l_Msg){
  48.         return true;
  49.     }else{
  50.         alert(alertMsg);
  51.         return false;
  52.     }
  53. }
  54.  
[html]
// -->
</script>



</head>


<body>

<div id="THANKS" style="display:none;">
&nbsp;<p>Thank you for submitting an e-Enrolment Form.
<a href="#" onClick="window.close();">Close</a>
</div>

<p>&nbsp;<form method="post" action="mailto:mail@web.co.uk?subject=EnrolReq" enctype="text/plain" subject="New User" name="FrontPage_Form1" onsubmit="return formCheck(this);" id="e_form" language="JavaScript" style="display:block;"> </div>
<table border="0" width="72%" id="table2" bgcolor="#FFFFCC">
<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>

<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>
<div id="submit_group" style="display:none;">
<table border="0" width="70%" id="table22" bgcolor="#CCFFFF">
<tr>
<td>
<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="hidden" name="EOR" value="">
<input type="Submit" value="Submit!">
<input type="reset" value="Clear Form">
</p>
</div>
</form>

</body>

</html>[/HTML]

I think the problem is somthing to do with the [HTML]<form method="post" action="mailto:mail@web.co.uk?subject=EnrolReq" enctype="text/plain" subject="New User" name="FrontPage_Form1" onsubmit="return formCheck(this);" id="e_form" language="JavaScript" style="display:block;"> </div>[/HTML] line.

HOWEVER........ it works ok when I preview it in my html editor, it's only when it's run through IE v6, it seems to just ignore the field validation.

Suggestions........
Aug 21 '07 #1
2 1721
pbmods
5,821 Recognized Expert Expert
Changed thread title to better describe the problem (did you know that threads whose titles contain phrases such as, 'problem' actually get FEWER responses?).
Aug 21 '07 #2
Logician
210 New Member
HOWEVER........ it works ok when I preview it in my html editor, it's only when it's run through IE v6, it seems to just ignore the field validation.
Tested in IE6 - works O.K. Are you sure your IE is running JS?
Aug 21 '07 #3

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

Similar topics

12
by: CJ | last post by:
Why won't this work? I am passing the name of the form (I have two that use this validation script) but I keep getting an error. Error reads: "document.which_form.name is null or not an object" ...
4
by: bnp | last post by:
Hi All, I am quite new the JavaScript. Basically I am a C++ programmer, but now I am working on JavaScript since last 5 days. I have a problem regarding the form validation. I have created a...
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
4
by: josh.dutcher | last post by:
I'm trying to set up a simple "change your password" form. I've got an AJAX process that is checking the new password the user enters against their current password to make sure they're changing...
9
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be...
27
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
19
by: zacks | last post by:
I have a .NET 2.0 MDI application where the child form has a Tab Control. Each of the Tab in the Tab Control has a Validating event to handle what it should do when the user changes tabs. But...
4
by: Stefan Hoffmann | last post by:
hi @all, I'm trying to validate a XML against a schema using the example from the MSDN: http://msdn.microsoft.com/en-us/library/system.xml.xmlreadersettings.validationtype.aspx In my case...
13
by: Andrew Falanga | last post by:
HI, Just a warning, I'm a javascript neophyte. I'm writing a function to validate the contents of a form on a web page I'm developing. Since I'm a neophyte, this function is quite simple at...
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
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...
1
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
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.