Jump to content

Javascript Object Expected Error in IE (Working Safari/Chrome/FF)


Pezmc

Recommended Posts

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

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

L21

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

L32

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

L34

onfocus="join_field(this,'p4ssxord')" onblur="leavefield(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?

 

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

 

// JavaScript Document
function join_field(what, text) {
if(what.value == text) {
	what.value=''; 
	what.style.color='#000';
}
}
function leavefield(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)
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.