IE6 Null or not an Object error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • severinsmith
    New Member
    • Sep 2008
    • 5

    #1

    IE6 Null or not an Object error

    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.commu nity.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.getEle mentById("image Field");
    var field_value = document.commun ity.EMAIL.value ;

    if ( (document.commu nity.EMAIL.valu e == "") || (email_pattern. test(field_valu e) == false) ) {
    button.disabled =true;
    return false;
    } else {
    button.disabled =false;
    }
    }

    if (document.all || document.getEle mentById) {
    setInterval("ch eckifempty()",1 00);
    }

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

    </script>[/HTML]
    Last edited by gits; Sep 4 '08, 12:50 PM. Reason: added code tags
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    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

    Comment

    • severinsmith
      New Member
      • Sep 2008
      • 5

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

      Code:
      
      <script type="text/javascript">
      
      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>
      
      
      <script src="http://recp.mkt32.net/ui/library/formValidate.js" type="text/javascript" language="javascript"></script>
      </head>
      
      <body>
      
      <form name="community" id="community" method="post" action="http://recp.mkt32.net/servlet/UserSignUp?f=112214&postMethod=HTML&m=0&j=MAS2">
      	<input type="hidden" name="EMAIL_REQUIRED" value="T" />
      	<input type="hidden" name="EMAIL_DATATYPE" value="" />
      
      	<label for="EMAIL">Sign up for e-mail updates.</label>
      
      	<input type="text" name="EMAIL" id="EMAIL" value="" size="20" maxlength="4000" />
      	<input type="image" name="imageField" id="imageField" src="graphics/btn_green_submit.gif" alt="Submit" />
      </form>
      
      </body>
      </html>

      Comment

      • severinsmith
        New Member
        • Sep 2008
        • 5

        #4
        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!

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          It's probably caused by this line:
          [code=javascript]setInterval("ch eckifempty()",1 00);[/code]Call it onload instead.

          Comment

          Working...