Pezmc Posted October 23, 2009 Share Posted October 23, 2009 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) } Quote Link to comment Share on other sites More sharing options...
lemmin Posted October 23, 2009 Share Posted October 23, 2009 I don't think this is a PHP question. Do you have a leave_field() function? I only see leavefield(). Quote Link to comment Share on other sites More sharing options...
Pezmc Posted October 23, 2009 Author Share Posted October 23, 2009 Sorry epic fail on the forum chosen... leave_field is the same as leavefield I was just testing removing the _ to see if it made a difference. Quote Link to comment Share on other sites More sharing options...
lemmin Posted October 26, 2009 Share Posted October 26, 2009 What version of internet explorer are you using? I just pasted that code and didn't get any errors. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.