views:

79

answers:

1

I'm using javascript to simulate a disabled select element. I can't actually disable it as the .net validators fail, but that's another story.

I have the following function:

function preventFocus(e) {
  if ($(this).hasClass("disabled")) {
    e.preventDefault();
    this.blur();
  }
}

That is called here:

$("#ProvinceID").toggleClass("disabled").bind('focus click dblclick', preventFocus);

Double-clicking the select box in IE still seems to allow the items to be displayed and selected. I tried the IE developer toolbar, and the e.type is showing up as focus and dblclick. Is this an IE bug, or do I need to catch some other event? I also tried focusin.

Thanks!

A: 

I don't know if it's just a typo, but you should use e.preventDefault(); looks like you were missing the parenthesis.

Mike Sherov
Typo, yes; answer, no. Thanks though.
ScottE