﻿// ==UserScript==
// @name                input内容格式判断
// @description	        这个框架用于各个input输入内容格式的判断, login.aspx, register.aspx(改用keerr.judgeForReg.js了), fb.aspx*4
// @created date        2009/01/01
// @created author      Tiger(tigershi0507@gmail.com)
// @version             2.0.2
// @version owner       Copyright © 2009-2010 keerr.com All rights reserved.
// ==/UserScript==

/********************************************************************
verified time 	:	2009/8/13   09:49
verified author	:	Tiger
verified purpose:	添加原来在keerr.validate.js中的Email判断（格式和ajax判断是否被注册，以传入的Options的键值对来控制）
*********************************************************************/
/********************************************************************
verified time 	:	2009/8/13   16:49
verified author	:	Tiger
verified purpose:	添加在页面初始化如果input有值时也需判断和样式切换的功能
*********************************************************************/
/********************************************************************
verified time   :   2009/8/21   9:27
verified author :   Martin
verified purpose:   输入的验证码转化为小写（if (_reg_checkCode == this.value.toLower() && this.value != "") ）
*********************************************************************/
/*************************************************
verified time 	:	2009/8/21   9:53
verified author	:	Tiger
verified purpose:	修正了当Input是password的类型是的empty判断
**************************************************/
/*************************************************
verified time 	:	2009/8/25   9:31
verified author	:	Tiger
verified purpose:	修改验证码自动刷新的bug，这个bug会造成自动focus到验证码的input上，无法进行别的input输入了
**************************************************/
/*************************************************
verified time 	:	2009/8/25   9:51
verified author	:	Tiger
verified purpose:	修改了之前focus，blur时input框的width会变化的不好样式变化
**************************************************/
/*************************************************
verified time 	:	2009/11/17   11:11
verified author	:	Tiger
verified purpose:	添加了注释，移动了_reg_checkCode到全局变量js中去了
**************************************************/
/*************************************************
verified time 	:	2009/11/17   16:22
verified author	:	Tiger
verified purpose:	以bylou的思考完成了这个插件的改进，使用了跳出层的样式
**************************************************/
/*************************************************
verified time 	:	2009/11/20   11:17
verified author	:	Tiger
verified purpose:	再次同意修改了这个js插件，使用了很多对象操作
**************************************************/
/*************************************************
verified time 	:	2009/12/2   10:18
verified author	:	Tiger
verified purpose:	完成对注册提示的修改
**************************************************/
/*************************************************
verified time 	:	2010/1/20   16:50
verified author	:	Tiger
verified purpose:	完成新的发布的js逻辑完善
**************************************************/
/*************************************************
verified time 	:	2010/1/21   11:15
verified author	:	Tiger
verified purpose:	完成判断上一个条目是否需要judge
**************************************************/
/*************************************************
verified time 	:	2010/1/28   14:11
verified author	:	Tiger
verified purpose:	在调试发布的时候碰到了很多问题，并对js进行了相关的改动，比如classToggle_focus将focus时去掉errMsgBox的事件放在全局执行了
**************************************************/
/*************************************************
verified time 	:	2010/3/4   16:23
verified author	:	Tiger
verified purpose:	修改一下
**************************************************/
/*************************************************
verified time 	:	2010/3/10   17:26
verified author	:	Tiger
verified purpose:	添加了性别radio的判断
**************************************************/
/********************************************************************
verified time 	:	2010/4/1   16:49
verified author	:	Tiger
verified purpose:	修改了isEmpty_ke的判断条件，以便适应copy操作
*********************************************************************/
/********************************************************************
verified time 	:	2010/5/6   14:13
verified author	:	Tiger
verified purpose:	完成了不规范字的js添加以及一些js的修订
*********************************************************************/

/// <summary>
/// 判断正确了加上judgeOK的class
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
(function ($) {
    // static options
    // s.msgBoxOptions
    var d = defaults = {
        ErrCls: "tooltipinputerr",
        OkCls: "tooltipinputok",
        //BGC_blur_err: "#FFFF99",
        //BGC_blur_ok: "#6DC360",
        BGC_focus: "#CCFF99",
        numberOfOk: 4,
        mustCheck: true,
        isLocal: false,
        isPublish: false,
        minWord: 0,
        msgBoxOptions: { errmsg: "", cssOptions: { top: "190px", left: "280px", opacity: "0.8" }, top: 30, left: 50, delay: 5000, clsName: "pswErrMsg", isID: false },
        // errmsg为空时采用读取DOM结构中的errmsg属性，否则使用输入的参数
        form: "#aspnetForm"
        // isID for ShowMsgbox(); delay === 0 为
    };
    // helper
    $.judgeHelper = {
        classToggle_blur_err: function ($_this) {
            $_this.removeClass(d.OkCls).addClass(d.ErrCls);
        },
        classToggle_blur_ok: function ($_this) {
            $_this.removeClass(d.ErrCls).addClass(d.OkCls);
        },
        classToggle_focus: function ($_this, thisID, preValue, boolPublish) {
            // 这里可以添加focus时是否清空input
            if ($_this.hasClass(d.ErrCls)) {
                $_this.val(preValue);
            }
            if ($_this.hasClass(d.OkCls)) {
            }
            $_this.removeClass(d.OkCls).removeClass(d.ErrCls).removeClass("judgeOK").css("border-color", "#bbb");
            if (boolPublish) {
                $_this.parents("td").removeClass("tooltipinputerr");

            }
            $("." + thisID).fadeOut().remove();
        },
        judgePreItem_focus: function ($_this) {
            var $_preItem = $_this.parents("tr").prevAll(".judgeItem");
            $_preItem.filter(function (index) {
                return $(this).hasClass("judgeOK");
            });
        },
        classToggle_clean: function ($_this) {
            $_this.removeClass(d.OkCls).removeClass(d.ErrCls);
        },
        autoDisplayErrMsg: function (s) {
            $(s.objSer).each(function () {
                if (!$(this).hasClass(d.OkCls) && !$(this).hasClass(d.ErrCls)) {
                    $.judgeHelper.classToggle_blur_err($(this));
                }
            });
        },
        localRight: function ($_this) {
            $_this.parents("li").find(".box-error").hide();
            $_this.parents("li").find(".box-right").show();
            $_this.addClass("judgeOk").css("border-color", "#29B520");
            $_this.keyup(function () {
                $_this.parents("li").find(".box-error").hide(); //.text("请输入正确的邮箱，完成注册");
                $_this.parents("li").find("#mg").show();
                if ($_this.attr("id") === "email") {
                    $_this.nextAll(".box-error").css("width", "312px").find("p").text("请正确填写您的有效邮箱地址，以便完成邮件激活注册");
                }
                if ($_this.attr("id") === "name") {
                    $_this.nextAll(".box-error").find("p").html('请输入<span style="color: red; font-weight: 700;">常用昵称</span>，方便朋友查找');
                }
            });
        },
        localError: function ($_this) {
            $_this.parents("li").find(".box-error").addClass("box-error-error").show();
            $_this.parents("li").find(".box-right").hide();
            $_this.removeClass("judgeOk");
            $_this.keyup(function () {
                if ($_this.attr("id") === "email" && $_this.parents("li").find(".box-error").hasClass("box-error-error")) {
                    $_this.parents("li").find(".box-error").css("width", "312px").find("p").text("请正确填写您的有效邮箱地址，以便完成邮件激活注册");
                }
                if ($_this.attr("id") === "name" && $_this.parents("li").find(".box-error").hasClass("box-error-error")) {
                    $_this.parents("li").find(".box-error").find("p").html('请输入<span style="color: red; font-weight: 700;">常用昵称</span>，方便朋友查找');
                }
                $_this.parents("li").find(".box-error").removeClass("box-error-error"); //.text("请输入正确的邮箱，完成注册");
            });
        },
        isKeyup: function ($_this) {
            $_this.keyup(function () {
                if ($_this.val() !== "" || $_this.val() !== null) {
                    $_this.addClass("_k");
                }
            }); ;
        },
        /// <summary>
        /// 统一的blur后的处理函数
        /// </summary>
        /// <param name="$_this">jQuery对象</param>
        /// <param name="v">input中的value</param>
        /// <param name="myreg">正则表达式</param>
        /// <param name="s">setting参数</param>
        blurRegCheck: function ($_this, v, myreg, s) {
            v = $.trim(v);
            if (s.mustCheck || v) {
                if (v !== "") {
                    var matchArr = (v.match(myreg) != null) ? ((v.match(myreg).length != 0) ? v.match(myreg) : []) : [],
                        flag = false; // 正则表达式的判断正确与否
                    for (var x = 0; x < matchArr.length; x++) {
                        if (matchArr[x] === v) {
                            flag = true;
                        }
                    }
                    if (s.isLocal) {    // 是否采用本地样式
                        if (!flag && v !== "") {
                            $.judgeHelper.localError($_this);
                        }
                        else {
                            $.judgeHelper.localRight($_this);
                        }
                    }
                    else {
                        if (!flag) {    // 正则表达式 不匹配
                            if (s.msgBoxOptions.errmsg === "") {
                                s.msgBoxOptions.errmsg = "请正确填写...";
                            }
                            ShowMsgbox(s.msgBoxOptions, $_this);
                            if (s.isPublish) {
                                $_this.parents("td").removeClass("tooltipinputok").addClass("tooltipinputerr");
                            }
                        }
                        else {  // 正则表达式 匹配
                            //if ($.trim(v) !== "") {
                            $_this.css("border-color", "#29B520").addClass("tooltipinputok");
                            if (s.isPublish) {
                                $_this.parents("td").addClass("judgeOK");
                            }
                            else {
                                $_this.removeClass("tooltipinputerr").addClass("judgeOK");
                            }
                            //}
                        }
                    }
                }
                else {
                    if (s.isLocal) {
                        $.judgeHelper.localError($_this);

                    } else {
                        ShowMsgbox(s.msgBoxOptions, $_this);
                        if (s.isPublish) {
                            $_this.parents("td").addClass("tooltipinputerr");
                        }
                    }
                }
            }
            else {
                if (s.isLocal) {
                    $_this.focus().nextAll(".box-error").removeClass("box-error-error");
                }
            }
        },
        /// <summary>
        /// 通过AJAX判断Email是否已被注册
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        checkEmail: function ($_this, v, myreg, s) {
            var matchArr = (v.match(myreg) != null) ? ((v.match(myreg).length != 0) ? v.match(myreg) : []) : [],
                flag = false;
            for (var x = 0; x < matchArr.length; x++) {
                if (matchArr[x] === v) {
                    flag = true;
                }
            }
            if (flag) {
                //if(v !== ""){
                $.post("/ajax/GetJson.aspx", { type: "regEmail", regEmail: v }, function (data, statut) {
                    if (data === "true") {
                        $.judgeHelper.localRight($_this);
                    }
                    else {
                        $.judgeHelper.localError($_this);
                        $_this.next(".box-error").find("p").text("该邮件已被注册");
                    }
                });
            }
            else {
                $.judgeHelper.localError($_this);
                //$.judgeHelper.classToggle_blur_err($_this);
                //$("#" + $_this.attr("id") + "_tishi").hide();
                //$("#" + $_this.attr("id") + "_msg").show().text("请确认输入正确的Email格式！");
            }
        },
        /// <summary>
        /// 通过AJAX判断昵称是否符合规范
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        checkNickName: function ($_this, v) {
            $.post("/ajax/GetJson.aspx", { type: "regUserName", regName: v }, function (data, statut) {
                if (data === "1") {
                    $.judgeHelper.localRight($_this);
                }
                else if (data === "0") {
                    $.judgeHelper.localError($_this);
                    $_this.next(".box-error").find("p").text("请使用规范昵称");
                }
            });
        }
    };
    /// <summary>
    /// judgeItem插件的主体
    /// </summary>
    $.fn.extend({
        isEmpty: function (options) {
            var s = options ? $.extend(true, {}, defaults, options) : defaults;
            return this.each(function () {
                var $_this = $(this),
                    myreg = /((\d*\D+\d*)|(\d+\D*\w*)|(\w+))+/g,    // 这里需要添加多种情况的正则表达式
                    preValue = "";
                //                if ($(this).val()) {
                //                    $.judgeHelper.blurRegCheck($_this, this.value, myreg, s);
                //                }

                $_this
                .blur(function () {
                    preValue = $.trim(this.value);
                    if ($(this).is("input:password")) {
                        if (this.value === "" || this.value.length < 6) {
                            if (s.isLocal) {
                                $.judgeHelper.localError($_this);
                            } else {
                                ShowMsgbox(s.msgBoxOptions, $_this);
                                if (s.isPublish) {
                                    $_this.parents("td").addClass("tooltipinputerr");
                                }
                            }
                        }
                        else {
                            $.judgeHelper.localRight($_this);
                            //myreg = /.{6,}/;
                            //$.judgeHelper.blurRegCheck($_this, this.value, myreg, s);
                        }
                    }
                    else {
                        if (preValue === "") {
                            if (s.isLocal) {
                                $.judgeHelper.localError($_this);
                            } else {
                                ShowMsgbox(s.msgBoxOptions, $_this);
                                if (s.isPublish) {
                                    $_this.parents("td").addClass("tooltipinputerr");
                                }
                            }
                        }
                        else {
                            //$.judgeHelper.blurRegCheck($_this, this.value, myreg, s);
                            if ($.trim($_this.attr("id")) === "name") {
                                $.judgeHelper.checkNickName($_this, $_this.val());
                            } else {
                                $.judgeHelper.blurRegCheck($_this, this.value, myreg, s);
                            }
                        }
                    }

                })
                .focus(function () {
                    $.judgeHelper.classToggle_focus($_this, this.id, preValue, s.isPublish);
                    //$.judgeHelper.judgePreItem_focus($_this);
                })
            });
        },
        isEmpty_ke: function (options, keSel) {
            var s = options ? $.extend(true, {}, defaults, options) : defaults;
            return this.each(function () {
                var $_this = $(this),
                //myreg = /((\d*\D+\d*)|(\d+\D*\w*)|(\w+))+/g,    // 这里需要添加多种情况的正则表达式
                    preValue = $.trim(KE.util.getPureData(keSel ? keSel : "ctl00_ContentPlaceHolder1_txtContent"));
                if ($("body").data("isEmpty") === 0 || preValue !== "") {
                    //$.judgeHelper.blurRegCheck($_this, $_this.val(), myreg, s);
                    //if (preValue.length > s.minWord || /<img/.test(preValue)) {
                    if (preValue.length > 2 || /<img/.test(preValue)) {             // ????????需要修改一下中文英文字符判断
                        $("." + s.parclsName).addClass("judgeOK");
                    }
                    else {
                        s.msgBoxOptions.errmsg = "发布字数至少2字以上";
                        ShowMsgbox(s.msgBoxOptions, $("." + s.parclsName));
                    }
                } else {
                    s.msgBoxOptions.errmsg = "请填写内容";
                    ShowMsgbox(s.msgBoxOptions, $("." + s.parclsName));
                    return false;
                }

            });
        },
        isInteger: function (options) {
            var s = options ? $.extend(true, {}, defaults, options) : defaults;
            return this.each(function () {
                var $_this = $(this),
                    myreg = /\d{1,}/g,
                    preValue = "";
                if ($(this).val()) {
                    $.judgeHelper.blurRegCheck($_this, this.value, myreg, s);
                }
                $_this
                .blur(function () {
                    preValue = this.value;
                    $.judgeHelper.blurRegCheck($_this, this.value, myreg, s);
                })
                .focus(function () {
                    $.judgeHelper.classToggle_focus($_this, this.id, preValue, s.isPublish);
                });

            });
        },
        isFloat: function (options) {
            var s = options ? $.extend(true, {}, defaults, options) : defaults;
            return this.each(function () {
                var $_this = $(this),
                    myreg = /\d+(.\d+)?/g,
                    preValue = "";
                if ($(this).val()) {
                    $.judgeHelper.blurRegCheck($_this, this.value, myreg, s);
                }
                $_this
                .blur(function () {
                    preValue = this.value;
                    $.judgeHelper.blurRegCheck($_this, this.value, myreg, s);
                })
                .focus(function () {
                    $.judgeHelper.classToggle_focus($_this, this.id, preValue, s.isPublish);
                });
            });
        },
        isEmail: function (options) {
            var s = options ? $.extend(true, {}, defaults, options) : defaults;
            return this.each(function () {
                var $_this = $(this),
                    myreg = /^[-_a-zA-Z0-9\.]{2,}@([_a-zA-Z0-9]+\.)+[a-zA-Z0-9]{2,3}$/g,
                    preValue = "";
                if ($(this).val()) {
                    $.judgeHelper.blurRegCheck($_this, this.value, myreg, s);
                }
                $_this
                .blur(function () {
                    preValue = this.value;
                    if (s.isUsed === true) {
                        $.judgeHelper.checkEmail($_this, this.value, myreg, s);
                    }
                    else {
                        $.judgeHelper.blurRegCheck($_this, this.value, myreg, s);
                    }

                })
                .focus(function (e) {
                    //var x = e.clientX;
                    $.judgeHelper.classToggle_focus($_this, this.id, preValue);
                });
            });
        },
        isPhone: function (options) {
            var s = options ? $.extend(true, {}, defaults, options) : defaults;
            return this.each(function () {
                var $_this = $(this),
                    myreg = /(((13|15|18)[0-9]\d{8})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/g,
                    preValue = "";
                if ($(this).val()) {
                    $.judgeHelper.blurRegCheck($_this, this.value, myreg, s);
                }
                $_this
                .blur(function () {
                    preValue = this.value;
                    $.judgeHelper.blurRegCheck($_this, this.value, myreg, s);
                })
                .focus(function () {
                    $.judgeHelper.classToggle_focus($_this, this.id, preValue, s.isPublish);
                });
            });
        },
        isValidate: function (options) {
            var s = options ? $.extend(true, {}, defaults, options) : defaults;
            return this.each(function () {
                var $_this = $(this),
                    preValue = "";
                $_this
                .blur(function () {
                    if (_reg_checkCode === this.value.toLowerCase() && this.value !== "") {
                        if (s.isLocal) {
                            $.judgeHelper.localRight($_this);
                        }
                        else {
                            $_this.css("border-color", "#73B402").addClass("tooltipinputok");
                        }
                    }
                    else {
                        //if (typeof _reg_checkCode === "undefined") {
                        //    getCode_reg();
                        //} else {

                        if (s.isLocal) {
                            $.judgeHelper.localError($_this);
                        }
                        else {
                            ShowMsgbox(s.msgBoxOptions, $_this);
                        }
                        //}
                        $('#codeimg').click();
                    }
                })
                .focus(function () {
                    $.judgeHelper.classToggle_focus($_this, this.id, preValue, s.isPublish);
                });
            });
        },
        isClicked: function (options) {
            var s = options ? $.extend(true, {}, defaults, options) : defaults;
            return this.each(function () {
                var $_this = $(this);

                $_this.find("input[name='sex']")
                .click(function () {

                    $_this.addClass("judgeOk").attr("value", $(this).attr("id"));
                }).attr();
            });
        },
        isReady: function (options) {
            var s = options ? $.extend(true, {}, defaults, options) : defaults;
            return this.each(function () {
                var $_this = $(this);
                $_this.click(function () {
                    $_this.attr("disabled", "disabled");
                    if ($.isFunction(s.readyFunction)) {
                        s.readyFunction(s);
                        $_this.attr("disabled", false);
                    }
                    else {
                        alert("type into a judge ready's function");
                        return false;
                    }
                });
            });
        },
        isReady_submit: function (options) {
            var s = options ? $.extend(true, {}, defaults, options) : defaults;
            return this.each(function () {
                var $_this = $(this);
                $(s.form).submit(function () {
                    $_this.attr("disabled", "disabled");
                    if ($.isFunction(s.readyFunction)) {
                        $_this.attr("disabled", false);
                        return s.readyFunction(s);
                    }
                    else {
                        alert("type into a judge ready's function");
                        return false;
                    }
                });
            });
        },
        isFunc: function (options) {
            var s = options ? $.extend(true, {}, defaults, options) : defaults;
            return this.each(function () {
                var $_this = $(this),
                    preValue = "";
                if ($(this).val()) {
                    $.judgeHelper.blurRegCheck($_this, this.value, myreg, s);
                }
                $_this
                .blur(function () {
                    preValue = this.value;
                    $.judgeHelper.blurRegCheck($_this, this.value, myreg, s);
                })
                .focus(function () {
                    $.judgeHelper.classToggle_focus($_this, this.id, preValue);
                });

            });
        },
        isSelect: function (options) {
            var s = options ? $.extend(true, {}, defaults, options) : defaults;
            return this.each(function () {
                var $_this = $(this),
                    $_mustSelect = $_this.find("select:last");

                $_mustSelect
                .change(function () {
                    if ($_mustSelect.val() !== "" && $_mustSelect.val() !== "0") {
                        $_this.addClass("judgeOK");
                    } else {
                        $_this.removeClass("judgeOK");
                    }
                });

            });
        }
    });
})(jQuery);

//$(function() {
//    // 基本判断
//    $(".judgeEmpty").isEmpty({isLocal:true});
//    $(".judgeInteger").isInteger();
//    $(".judgeFloat").isFloat();
//    $(".judgeEmail").isEmail({ isUsed: false });
//    $(".judgePhone").isPhone();
//    // 不是必须判断
//    $(".judgeEmptyNotMust").isEmpty({ mustCheck: false });
//    $(".judgeIntegerNotMust").isInteger({ mustCheck: false });
//    $(".judgeFloatNotMust").isInteger({ mustCheck: false });
//    $(".judgeEmailNotMust").isEmail({ mustCheck: false, isUsed: false });
//    $(".judgePhoneNotMust").isPhone({ mustCheck: false });
//    // 判断Email是否已经被使用，主要是用在注册页面
//    $(".judgeEmailIsUsed").isEmail({ isUsed: true });
//    // 判断验证码
//    $(".judgeValidate").isValidate();
//    // 判断能否上传数据到DB
//    $(".judgeValidateNotMust").isValidate({ mustCheck: false });
//    $(window).unload(function() {
//        $(".tooltipinputerr").val("");
//    });

//    $("#txtU").isEmail({ isUsed: false, isFloatOut: true, msgBoxOptions: { errmsg: "请输入账号", cssOptions: { top: "130px", left: "280px", opacity: "0.8" }, delay: 5000, clsName: "userNameErrMsg"} });

//});


function filterStr(str) {
    str = str.replace(/<\/?[^>]*>/g, '');
    str = str.replace(/[ | ]*\n/g, '\n');
    str = str.replace(/\n[\s| | ]*\r/g, '\n');
    return str;
}

//var _reg_checkCode; 添加到了全局变量的js中去了
/// <summary>
/// 获取验证码
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
function getCode_reg() {
    $.ajax({
        url: '/ajax/GetJson.aspx',
        type: 'POST',
        dataType: 'text',
        timeout: 3000,
        data: { type: "getImgSession" },
        cache: false,
        error: function() {
        },
        success: function(str) {
            if (str != '0') {
                _reg_checkCode = str;

            }
        }
    });
}

/// <summary>
/// 更改验证码
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
function changeCode_reg(imgId) {
    var obj = $(imgId);
    if (obj) {
        obj.attr("src", "/codeImager2.aspx?d=" + Math.random());
        getCode_reg();
        $("#icode, #txtC").val("").css("border-color", "#BBBBBB");
    }
}

/// <summary>
/// 获取login错误次数并填写入_LoginErrNumber这个全局变量
/// </summary>
/// <param name=""></param>
/// <param name=""></param>
function getLoginErrNumber() {
    $.ajax({
        url: '/ajax/GetJson.aspx',
        type: 'POST',
        dataType: 'text',
        timeout: 3000,
        data: { type: "getLgErrNumSession" },
        cache: false,
        error: function() {
        },
        success: function(str) {
            if (str != '0') {
                _LoginErrNumber = str;
                if (_LoginErrNumber > 9) {
                    $(".lg_hlp li:gt(2)").hide();
                    $("#licode").show(); //css("display", "");
                }
            }
        }
    });
}

/// <summary>
/// 显示错误并提示错误信息
/// </summary>
/// <param name="msgOpt">只接受关于这个msgbox的options</param>
/// <param name="$_this">input对象</param>
var timeOutOpt;
function ShowMsgbox(msgOpt, $_this) {
    if (msgOpt.isID) {  // 有id者的msgbox使用它们的id来标注class，以便唯一
        msgOpt.clsName = $_this.attr("id");
    }
    if ($("." + msgOpt.clsName).length === 0) {
        clearTimeout(timeOutOpt);
        $("body").append('<div class="formError ' + msgOpt.clsName + '" style="display: none;">' +
                            '<div class="formErrorContent">' +
                               ' * This is not available</div>' +
                            '<div class="formErrorArrow">' +
                                '<div class="line10">' +
                                    '<!-- -->' +
                                '</div>' +
                                '<div class="line9">' +
                                    '<!-- -->' +
                                '</div>' +
                                '<div class="line8">' +
                                    '<!-- -->' +
                                '</div>' +
                                '<div class="line7">' +
                                    '<!-- -->' +
                                '</div>' +
                                '<div class="line6">' +
                                    '<!-- -->' +
                                '</div>' +
                                '<div class="line5">' +
                                    '<!-- -->' +
                                '</div>' +
                                '<div class="line4">' +
                                    '<!-- -->' +
                                '</div>' +
                                '<div class="line3">' +
                                    '<!-- -->' +
                                '</div>' +
                                '<div class="line2">' +
                                    '<!-- -->' +
                                '</div>' +
                                '<div class="line1">' +
                                    '<!-- -->' +
                                '</div>' +
                            '</div>' +
                        '</div>');
    };

    msgOpt.cssOptions.top = $_this.offset().top - msgOpt.top;
    msgOpt.cssOptions.left = $_this.offset().left + $_this.innerWidth() - msgOpt.left;
    $("." + msgOpt.clsName).css(msgOpt.cssOptions).fadeIn().find(".formErrorContent").text(msgOpt.errmsg ? msgOpt.errmsg : $_this.attr("errMsg"));
    if (msgOpt.delay !== 0) {
        timeOutOpt = setTimeout(function() {
            $("." + msgOpt.clsName).fadeOut().remove();
        }, msgOpt.delay);
    }

    //    if ($.browser.version === "6.0") {
    //        $(".formError").bgiframe();
    //    }

    $_this
    .addClass("tooltipinputerr");
    //    .focus(function() {
    //        $("." + msgOpt.clsName).fadeOut().remove();
    //    });
}


