Connecting Tech Pros Worldwide Help | Site Map

IE6 Null or not an Object error

  #1  
Old September 4th, 2008, 01:39 PM
Newbie
 
Join Date: Sep 2008
Posts: 5
Hi,
I need to have a form button disabled until the user enters a valid email address. I get the following error message in IE6

'document.community.EMAIL' is null or not an object

Not great at javascript, and any help would REALLY be appreciated.
TIA

---

Code follows:

[HTML]function checkifempty(){

var email_pattern = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var button = document.getElementById("imageField");
var field_value = document.community.EMAIL.value;

if ( (document.community.EMAIL.value == "") || (email_pattern.test(field_value) == false) ) {
button.disabled=true;
return false;
} else {
button.disabled=false;
}
}

if (document.all || document.getElementById) {
setInterval("checkifempty()",100);
}

function emailcheck(form) {
if (document.community.EMAIL.value == "" || document.community.EMAIL.value.indexOf('@', 0) == -1)
alert("Sorry, we cannot process that request. Please try again.");
}

</script>[/HTML]

Last edited by gits; September 4th, 2008 at 01:50 PM. Reason: added code tags
  #2  
Old September 4th, 2008, 02:16 PM
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,488
Provided Answers: 9

re: IE6 Null or not an Object error


Hi Tia,

I need to see the html code too, in case there went something wrong with the naming (you can't see those issues in the script code).

regards
  #3  
Old September 4th, 2008, 02:26 PM
Newbie
 
Join Date: Sep 2008
Posts: 5

re: IE6 Null or not an Object error


Awesome, thanks! I stripped all doctypes and css..
Code follows (I hope I did it right this time)

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <script type="text/javascript">
  4.  
  5. function checkifempty(){
  6.  
  7.     var email_pattern = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
  8.     var button = document.getElementById("imageField");
  9.     var field_value = document.community.EMAIL.value;
  10.  
  11.     if ( (document.community.EMAIL.value == "") || (email_pattern.test(field_value) == false) ) {
  12.         button.disabled=true;
  13.         return false;
  14.     } else {
  15.         button.disabled=false;
  16.         }
  17.     }
  18.  
  19.     if (document.all || document.getElementById) {
  20.         setInterval("checkifempty()",100);
  21.     }
  22.  
  23. function emailcheck(form) {
  24.     if (document.community.EMAIL.value == "" || document.community.EMAIL.value.indexOf('@', 0) == -1)
  25.         alert("Sorry, we cannot process that request. Please try again.");
  26.     }
  27.  
  28. </script>
  29.  
  30.  
  31. <script src="http://recp.mkt32.net/ui/library/formValidate.js" type="text/javascript" language="javascript"></script>
  32. </head>
  33.  
  34. <body>
  35.  
  36. <form name="community" id="community" method="post" action="http://recp.mkt32.net/servlet/UserSignUp?f=112214&postMethod=HTML&m=0&j=MAS2">
  37.     <input type="hidden" name="EMAIL_REQUIRED" value="T" />
  38.     <input type="hidden" name="EMAIL_DATATYPE" value="" />
  39.  
  40.     <label for="EMAIL">Sign up for e-mail updates.</label>
  41.  
  42.     <input type="text" name="EMAIL" id="EMAIL" value="" size="20" maxlength="4000" />
  43.     <input type="image" name="imageField" id="imageField" src="graphics/btn_green_submit.gif" alt="Submit" />
  44. </form>
  45.  
  46. </body>
  47. </html>
  48.  
  49.  
  50.  
  #4  
Old September 4th, 2008, 04:50 PM
Newbie
 
Join Date: Sep 2008
Posts: 5

re: IE6 Null or not an Object error


It looks like the issue is that IE6 parses the head first, and doesn't recognize the form in the body. If I physically move the script after the form, I no longer get the error. Does this sound correct?

If anyone has any input about this, or other ways to do it, it would be great!

Now with the JS on the page, I'll get validation errors....grrr! IE6!
  #5  
Old September 4th, 2008, 06:03 PM
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,522
Provided Answers: 12

re: IE6 Null or not an Object error


It's probably caused by this line:
Expand|Select|Wrap|Line Numbers
  1. setInterval("checkifempty()",100);
Call it onload instead.
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft JScript runtime error: 'ol' is null or not an object suganya answers 3 August 6th, 2008 02:09 PM
"...is null or not an object" error when creating draggable divs cleary1981 answers 6 July 9th, 2008 04:14 PM
IE SP2 solution for "null is null or not an object" and "broken" insertCell/insertRow putty answers 1 July 23rd, 2005 07:58 PM
value is null or not an object -- after a few submits AC answers 6 July 20th, 2005 03:42 PM