Javascript Object Expected Error in IE

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Pezmc
Forum Commoner
Posts: 53
Joined: Mon Nov 06, 2006 2:15 pm

Javascript Object Expected Error in IE

Post by Pezmc »

Simple JS to clear fields and enable/disable a submit button, it works fine in all browsers except IE (grr...)

IE throws a Object expected error on line 19, 21, 32 & 34 of the html
L19

Code: Select all

onfocus="join_field(this,'email@hotmail.co.uk')" onblur="leave_field(this,'email@hotmail.co.uk')" /></p>
L21

Code: Select all

onfocus="join_field(this,'p4ssxord')" onblur="leave_field(this,'p4ssxord')" /></p>
L32

Code: Select all

onfocus="join_field(this,'03cucjamf')" onblur="leave_field(this,'03cucjamf')" /></p>
L34

Code: Select all

onfocus="join_field(this,'p4ssxord')" onblur="leave_field(this,'p4ssxord')"  /></p>
I have absolutely no idea what is causing this error. Why is IE always so different?
Does anyone know what is causing it & how to fix it?

Code: Select all

<form id="activate" name="activate" method="post" action="">
        <div class="legend">Activate Your Account</div>
        <div class="form"> 
              <p><label for="username">SLS Username: </label><input type="text" name="username" id="username" value="03cucjamf"
                    onfocus="join_field(this,'03cucjamf')" onblur="leave_field(this,'03cucjamf')" /></p>
              <p><label for="password">SLS Password: </label><input type="password" name="password" id="password" value="p4ssxord"
                    onfocus="join_field(this,'p4ssxord')" onblur="leavefield(this,'p4ssxord')"  /></p>
              <p><input type="submit" name="submit" id="activateb" value="Activate" disabled="disabled" /></p>
        </div>
      </form>

Code: Select all

// JavaScript Document
function join_field(what, text) {
    if(what.value == text) {
        what.value=''; 
        what.style.color='#000';
    }
}
function leave_field(what, text) {
    if(what.value == '') {
        what.value=text;
        what.style.color='#888';
    }
}
function checkifempty() {
    if (document.login.username.value!=='email@hotmail.co.uk'&&document.login.username.value!=='') {
        if(document.login.password.value!=='p4ssxord'&&document.login.password.value!=='') {
            document.login.loginb.disabled=false;
            document.login.loginb.style.color = "#000";
            document.login.loginb.style.border = "1px #000 solid";
        } else {
            document.login.loginb.disabled=true;
            document.login.loginb.style.color = "#888";
            document.login.loginb.style.border = "1px #ccc solid";
        }
    } else {
        document.login.loginb.disabled=true;
        document.login.loginb.style.color = "#888";
        document.login.loginb.style.border = "1px #ccc solid";
    }
    if (document.activate.username.value!=='email@hotmail.co.uk'&&document.activate.username.value!=='') {
        if(document.activate.password.value!=='p4ssxord'&&document.activate.password.value!=='') {
            document.activate.activateb.disabled=false;
            document.activate.activateb.style.color = "#000";
            document.activate.activateb.style.border = "1px #000 solid";
        } else {
            document.activate.activateb.disabled=true;
            document.activate.activateb.style.color = "#888";
            document.activate.activateb.style.border = "1px #ccc solid";
        }
    } else {
        document.activate.activateb.disabled=true;
        document.activate.activateb.style.color = "#888";
        document.activate.activateb.style.border = "1px #ccc solid";
    }
}
if (document.all || document.getElementById) {
    setInterval("checkifempty()",100)
}
Post Reply