开发者

Weird behavior with .blur on Internet Explorer

For IE, I was trying to set the .blur so focus would be taken out of the field with the error state.

I tried to work it in below and it wasn't working, no matter what I tried. (continue reading below)

function customAlert(){
    var args = arguments;
    if(args.length > 1) {
        // check that custom alert was called with at least two arguments
        var msg = args[0];
        $("li").removeClass("alertRed");
        $("input").removeClass("CO_form_alert");
        $("select").removeClass("CO_form_alert");
        var div = $(".errorPopup");
        div.css({"display":"block"});
        if (div.length == 0) {
            div = $("<div class='errorPopup' onclick='$(this).hide();'></div>");
            $("body").prepend(div);
        }
        div.html(msg);
        for(var i = 1; i < args.length; i++) {
            var inputID = args[i];
           $("#"+inputID).addClass("CO_form_alert").parent().addClass("alertRed");
            $("#"+inputID).focus(function(){
                $(this).unbind('focus'); // remove this handler
                $('.errorPopup').hide(); // hide error popup

            });
        }
     }
}

So then I added .blur to the javascript validation, which works (oddly) in IE6 - if another window is open, it's removing focus from the entire browser and the browser window will minimize. Thoughts? - seems strange

case "firstName":
                        //First Name Field Validation, Return false if field is empty
                        if( f.firstName.value == "" )
                        {
                            customAlert (bnadd_msg_002,"firstName");
                            if ((typeof TeaLeaf != "undefined") && (typeof TeaLeaf.Client != "undefined") && (typeof TeaLeaf.Client.tlAddEvent != "undefined") ) {
                                var nVO = { ErrorMessage : 开发者_C百科bnadd_msg_002}
                                var subtype="CustomErrorMsg";
                                TeaLeaf.Event.tlAddCustomEvent(subtype, nVO);
                                    }
                              (this).blur();
                            return false;
                        }
                        break;


$('#myInput').blur();

Or...

$('#mySubmitButton').focus();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜