(function () { if (window["globalstech_js"]) { return; } if (typeof globalstech === "undefined") { globalstech = function () { }; } // var windows = []; globalstech.stopbubble = function (e) { //一般用在鼠标或键盘事件上 if (e && e.stoppropagation) { //w3c取消冒泡事件 e.stoppropagation(); } else { //ie取消冒泡事件 window.event.cancelbubble = true; } }; globalstech.closepopup = function (mid, refresh) { if (refresh != false && (refresh == undefined || refresh == "")) { refresh = true; } if (window.closepopupallowrefresh) { refresh = true; } if (parent) { var ipopup = parent.jquery("#ipopup"); if (ipopup.length > 0 && ipopup.dialog) { ipopup.dialog("close"); } if (window.parent.openedwindow) { window.parent.openedwindow.refresh = refresh; window.parent.openedwindow.close(); window.parent.openedwindow.isshow = false; } } return false; }; globalstech.closepopupandrefreshpage = function () { if (parent) { if (window.parent.openedwindow) { window.parent.openedwindow.isshow = false; window.parent.openedwindow.close(); } parent.location.href = parent.location.href; } }; globalstech.popupsetsize = function (width, height) { var wnd = window.openedwindow; if (!wnd) { wnd = parent.window.openedwindow; } if (wnd) { wnd.setsize(width, height); } } //刷新父级模块 globalstech.refreshparent = function (mid) { if (parent && mid) { var pmodule = parent.window["module" + mid]; if (pmodule) { //设置异步刷新的来源 parent.$("#ajaxrefreshcommand" + mid).val(window["module" + mid].options.uniquename); //刷新模块 pmodule.refreshmodule(); } } } //刷新父级模块 globalstech.refresh = function (mid, uniquename, valid) { if (mid && (!window["openedwindow"] || openedwindow.refresh == undefined || openedwindow.refresh == true)) { var module = window["module" + mid]; if (module) { //设置异步刷新的来源 // $("#ajaxrefreshcommand" + mid).val(uniquename); module.setajaxrefreshcommand(uniquename); //刷新模块 module.refreshmodule(); } } } //弹窗 globalstech.showpopup = function (url, mid) { if (url.indexof("popup=true") == -1) { if (url && url.indexof("?") == -1) { url += "?"; } else { url += "&"; } url += "popup=true"; } if (!window.openedwindow) { window.openedwindow = $find("globalstech_window"); //弹窗 if (window.openedwindow && mid) { window.openedwindow.add_beforeclose(function (sender, args) { window.openedwindow.isshow = false; var module = window["childmodule" + mid]; if (module) { try { var form = $(".radwindow iframe").get(0).contentwindow.document.forms[0]; if (module.options.validformisdirty) {//如果开启表单修改验证 if (globalstech.formisdirty(form)) { if (!confirm("对不起,页面数据已做修改,尚未保存,确定要刷新或离开本页面?")) { args.set_cancel(true); return false; } } } } catch (e) { } } if (window.openedwindow.refresh) { if (module) { window.globalstech.refresh(mid, module.options.uniquename); } else { window.globalstech.refresh(mid, ""); } } //还原父页面的滚动条 if (window.parent) { window.parent.$(document.body).css("overflow-y", "auto"); } }); } } window.openedwindow.seturl(url); var module = globalstech.getmodule(mid); if (module) { var moduleoptions = module.options; if (moduleoptions.autosize) { window.openedwindow.setsize($(window).width() * 0.9, $(window).height() * 0.9); } } //如果页面url设置宽高 var req = new globalstech.querystring(url); var w = req["w"]; var h = req["h"]; if (w && h) { window.openedwindow.setsize(parseint(w), parseint(h)); } /* if (window["popuptitle"]) { globalstech.setpopuptitle(window.popuptitle); }*/ window.openedwindow.show(); window.openedwindow.isshow = true; if (window.parent && window.parent.openedwindow && window.parent != self) { var width = window.parent.openedwindow.get_width(); var height = window.parent.openedwindow.get_height(); window.openedwindow.setsize(width * 0.9, height * 0.9); window.openedwindow.center(); } //屏蔽父页面的滚动条 if (window.parent) { window.parent.$(document.body).css("overflow-y", "hidden"); } } /* globalstech.setpopuptitle = function (title) { if (window.openedwindow) { settimeout(function () { window.openedwindow.set_title(title); }, 50); } } */ globalstech.showpopuponready = function (url, mid) { if (window["sys"]) { if (!sys.webforms.pagerequestmanager.getinstance().get_isinasyncpostback()) {//仅在非异步刷新时加载窗口 settimeout(function () { globalstech.showpopup(url, mid); }, 50); } } else { $(function () { settimeout(function () { globalstech.showpopup(url, mid); }, 50); }); } } globalstech.ajaxrequest = function (args) { var ajaxmanager = globalstech.getajaxmanager(); if (ajaxmanager != null) { ajaxmanager.ajaxrequest(args); } }; globalstech.ajaxrequestwithtarget = function (id, args) { var ajaxmanager = globalstech.getajaxmanager(); if (ajaxmanager != null) { ajaxmanager.ajaxrequestwithtarget(id, args); } }; globalstech.getajaxmanager = function () { return $find("ajaxmanager"); }; globalstech.toolbarclicking = function (gridclientid) { return function (sender, args) { var button = args.get_item(); var value = button.get_value(); var grid = $find(gridclientid); var attrs = button.get_attributes(); switch (value) { case "delete": if (!confirmselected("请选择要删除的项")) { return; } var message = "是否删除选择中项?"; if (sender.finditembyvalue("restore")) { message = "是否从回收站中彻底删除,注意此删除无法恢复?"; } if (!confirm(message)) { args.set_cancel(true); } break; case "restore": if (!confirmselected("请选择要还原的项")) { return; } if (!confirm("是还原除选择中项?")) { args.set_cancel(true); } break; } if (window["toolbarclicking"] && $.isfunction(window["toolbarclicking"])) { if (!window["toolbarclicking"](sender, args, grid)) { args.set_cancel(true); return; } } var verifycheck = attrs.getattribute("verify-check"); var verifycheckmessage = attrs.getattribute("verify-check-message"); if (verifycheck == "true") { if (!confirmselected(verifycheckmessage)) { return; } } function confirmselected(message) { if (grid && grid.get_selecteditems().length == 0) { globalstech.tip.show({ text: message, type: "warning", maxcount: 1 }); args.set_cancel(true); return false; } return true; } }; }; globalstech.formisdirty = function (form) { if (!form) { form = $("form").get(0); } if (!form) { return false; } for (var i = 0; i < form.elements.length; i++) { var element = form.elements[i]; var type = element.type; if (type == "checkbox" || type == "radio") { if (element.checked != element.defaultchecked) { return true; } } else if (type == "hidden" || type == "password" || type == "text" || type == "textarea") { if (element.value != element.defaultvalue) { return true; } } else if (type == "select-one" || type == "select-multiple") { for (var j = 0; j < element.options.length; j++) { if (element.options[j].selected != element.options[j].defaultselected) { return true; } } } } return false; }; globalstech.modulebase = function (options) { var that = this; this.options = options; this.cancelclosewindow = false; //刷新模块 this.refreshmodule = function () { var button = $("#" + that.options.refreshbuttonid); var href = button.attr("href"); if (href) { var script = href.replace("javascript:", ""); eval(script); } }; //设置刷新命令 this.setajaxrefreshcommand = function (command) { $("#ajaxrefreshcommand" + that.options.mid).val(command); } //将当前对象设置到父页面中 if (parent && parent != self) { parent.window["childmodule" + this.options.mid] = this; } }; globalstech.getmodule = function (mid) { return window["module" + mid]; }; globalstech.htmlencode = function (html) { var temp = document.createelement("div"); (temp.textcontent != null) ? (temp.textcontent = html) : (temp.innertext = html); var output = temp.innerhtml; temp = null; return output; } globalstech.htmldecode = function (text) { var temp = document.createelement("div"); temp.innerhtml = text; var output = temp.innertext || temp.textcontent; temp = null; return output; } // globalstech.querystring = function (url) { // var url = location.search; //获取url中"?"符后的字串 var therequest = new object(); if (!url) { return therequest; } var pathname = url.replace(/http:\/\/(.*?)\//ig, ""); pathname = pathname.substring(1, pathname.length); pathname = pathname.replace(/\/default\.aspx.*/ig, ""); pathname = pathname.replace(/\/\//ig, "/"); var items = pathname.split("/"); for (var index = 0; index < (items.length / 2) ; index++) { var key = items[index * 2]; var value = items[index * 2 + 1]; therequest[key] = value; } if (url.indexof("?") != -1) { var str = url.split("?")[1]; strs = str.split("&"); for (var i = 0; i < strs.length; i++) { therequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]); } } return therequest; } if (parent && parent.window["popuptitle"]) { if (parent.window.openedwindow) { settimeout(function () { parent.window.openedwindow.set_title(parent.window["popuptitle"]); }, 1); } } var validintervalid; var groups = {}, defaultrules = {}, defaultmessages = {}; var validateoptions = { rules: defaultrules, messages: defaultmessages, errorelement: "label", ignore: ".ignore", onfocusout: function (element) { $(element).valid(); }, onkeyup: function (element, e) { //输入间隔内不验证 if (validintervalid) { cleartimeout(validintervalid); } validintervalid = settimeout(function () { $(element).valid(); }, 500); }, success: function (label) { label.html(" ").addclass("valid"); }, errorplacement: function (error, element) { if (element.data("tip") == true) { var offsetx = element.data("offsetx") || (element.width() + 25); var offsety = element.data("offsety") || (element.height() / 2); error.css({ left: (element.position().left + offsetx) + "px", top: (element.position().top + offsety) + "px", position: "absolute" }); } var raddropdownlist = element.closest(".raddropdownlist"); if (raddropdownlist.length > 0) { raddropdownlist.after(error); return; } var radasyncupload = element.closest(".radasyncupload"); if (radasyncupload.length > 0) { radasyncupload.after(error); return; } // var id = element.attr("id"); if (element.data("target-id")) { error.appendto($("#" + element.data("target-id"))); } else { var id = element.attr("name").replace(/\$/ig, "_"); var parent; if (id == element.attr("id")) { parent = element.parent(); } else { parent = $("#" + element.attr("id")).parent(); } error.appendto(parent); } }, highlight: function (element, errorclass, validclass) { var id = element.name.replace(/\$/ig, "_"); if (id == element.id) { if (element.type === "radio") { this.findbyname(element.name).addclass(errorclass).removeclass(validclass); } else { $(element).addclass(errorclass).removeclass(validclass); } } else { $("#" + id).addclass(errorclass).removeclass(validclass); } }, unhighlight: function (element, errorclass, validclass) { var id = element.name.replace(/\$/ig, "_"); if (id == element.id) { if (element.type === "radio") { this.findbyname(element.name).removeclass(errorclass).addclass(validclass); } else { $(element).removeclass(errorclass).addclass(validclass); } } else { $("#" + id).removeclass(errorclass).addclass(validclass); } } }; globalstech.addvalidators = function (formvalidators) { var rules = {}; var messages = {}; function buildvalidate(description, property) { if (!property || !description || !description.name) { return; } if (description[property]) { (rules[description.name])[property] = description[property]; } var msgproperty = property + "_msg"; if (description[msgproperty]) { (messages[description.name])[property] = description[msgproperty];; } } if (formvalidators) { for (var index in formvalidators) { var validateoption = formvalidators[index]; if (validateoption.group) { //如果设置了分组 if (!groups[validateoption.group]) { var group = groups[validateoption.group] = {}; group.rules = {}; group.messages = {}; rules = group.rules; messages = group.messages; } else { rules = groups[validateoption.group].rules; messages = groups[validateoption.group].messages; } } else { rules = defaultrules; messages = defaultmessages; } var name = validateoption.name; if (!rules[name]) { rules[name] = {}; } if (!messages[name]) { messages[name] = {}; } buildvalidate(validateoption, "required"); buildvalidate(validateoption, "max"); buildvalidate(validateoption, "min"); buildvalidate(validateoption, "maxlength"); buildvalidate(validateoption, "minlength"); buildvalidate(validateoption, "equalto"); buildvalidate(validateoption, "range"); buildvalidate(validateoption, "rangelength"); //todo 多个表达式 if (validateoption.exp) { if (validateoption.exp[0] == "^") { buildvalidate(validateoption, "exp"); } else { rules[name][validateoption.exp] = validateoption.exp; messages[name][validateoption.exp] = validateoption.exp_msg; } } if (validateoption.remote) { if (validateoption.remote_elementid) { var id = validateoption.remote_elementid; rules[name]["remote"] = { url: validateoption.remote, data: { value: function () { return encodeuricomponent($("#" + id).val()); } } }; } else { rules[name]["remote"] = validateoption.remote; } messages[name]["remote"] = validateoption.remote_msg; } } } } globalstech.getvalidatoroptions = function (group) { if (!group) { group = globalstech.currentvalidatorgroup; } var groupinfo = groups[group]; if (groupinfo) { validateoptions.rules = groupinfo.rules; validateoptions.messages = groupinfo.messages; } return validateoptions; } globalstech.setvalidatorgroup = function (group) { var validator = globalstech.getvalidatoroptions(group); $("form").data("validator", null).validate(validator); } window.globalstech = globalstech; globalstech.ajax = function (mid, root, service, method, data, type) { if (!$.servicesframework) { alert("web api servicesframework 未初始化."); return {}; } if (!type) { type = "get"; } var serviceframework = $.servicesframework(mid); var path = serviceframework.getserviceroot(root) + service + '/'; return $.ajax({ type: type, url: path + method, beforesend: serviceframework.setmoduleheaders, data: data, cache: false }); } globalstech.download = function (url) { globalstech.tip.show({ text: "正在下载文件,请稍等", type: "warning", position: "middle-center" }); var downloader; downloader = document.getelementbyid("downloader"); if (!downloader) { downloader = document.createelement("iframe"); downloader.id = "downloader"; downloader.style.display = "none"; document.body.appendchild(downloader); } if (downloader) { downloader.src = url; } }; window["globalstech_js"] = true; })(); //浮动提示框 (function () { var settings = { ineffect: { opacity: 'show' }, // in effect ineffectduration: 600, // in effect duration in miliseconds staytime: 4000, // 停留时间 text: '', // sticky: false, // 是否不自动关闭 type: 'info', // notice, warning, error, success position: 'top-full', // 左上= top-left, 上中= top-center,右上=top-right,中左= middle-left,中= middle-center,中右= middle-right closetext: '', //关闭文本 close: null, // 关闭回调 maxcount: 1 }; var wrap = {}; globalstech.tip = { show: function (options) { if (parent && parent != self && top) { top.globalstech.tip.show(options); return; } var localsettings = $.extend({}, settings, options); var tipwrap, itemouter, iteminner, itemclose, itemimage; if (!wrap[localsettings.position]) { wrap[localsettings.position] = $('
').addclass('tip-container').addclass('tip-position-' + localsettings.position).appendto('body'); } tipwrap = wrap[localsettings.position]; if (localsettings.maxcount <= 1) { $(".tip-item", tipwrap).remove(); } else { var count = tipwrap.children().length; if (count >= localsettings.maxcount) { globalstech.tip.remove($(".tip-item", tipwrap).first(), localsettings); } } itemouter = $('
').addclass('tip-item-wrapper'); iteminner = $('
').hide().addclass('tip-item tip-type-' + localsettings.type); iteminner = iteminner.appendto(tipwrap); iteminner = iteminner.html($('') .append(localsettings.text)) .animate(localsettings.ineffect, localsettings.ineffectduration) .wrap(itemouter); itemclose = $('
').addclass('tip-item-close').prependto(iteminner).html(localsettings.closetext).click(function () { globalstech.tip.remove(iteminner, localsettings); }); itemimage = $('
').addclass('tip-item-image').addclass('tip-item-image-' + localsettings.type).prependto(iteminner); if (navigator.useragent.match(/msie 6/i)) { tipwrap.css({ top: document.documentelement.scrolltop }); } //重新计算居中 if (localsettings.position == "middle-center") { var left = ($(document.body).width() - tipwrap.width()) / 2; tipwrap.css({ left: left + 100 }); } if (!localsettings.sticky) { settimeout(function () { globalstech.tip.remove(iteminner, localsettings); }, localsettings.staytime); } }, remove: function (obj, options, fn) { obj.animate({ opacity: '0' }, 600, function () { obj.parent().animate({ height: '0px' }, 300, function () { var parent = obj.parent(); (fn && fn()); parent.remove(); }); }); if (options && options.close !== null) { options.close(); } }, notice: function (message, pos, time) { this.show({ text: message, type: "notice", position: pos || "middle-center", staytime: time }); } , warning: function (message, pos, time) { this.show({ text: message, type: "warning", position: pos || "middle-center", staytime: time }); } , error: function (message, pos, time) { this.show({ text: message, type: "error", position: pos || "middle-center", staytime: time }); } , success: function (message, pos, time) { this.show({ text: message, type: "success", position: pos || "middle-center", staytime: time }); } }; globalstech.showtip = function (msg, type, pos, time) { globalstech.tip.show({ text: msg, type: type, position: pos, staytime: time }); } globalstech.showerror = function (msg, pos, time) { globalstech.tip.error(message, pos, time); } globalstech.showwarning = function (msg, pos, time) { globalstech.tip.warning(msg, pos, time); } globalstech.showsuccess = function (msg, pos, time) { globalstech.tip.success(msg, pos, time); } globalstech.shownotice = function (msg, pos, time) { globalstech.tip.notice(msg, pos, time); } })(); $(function () { var scrolltimeout = false; $(window).scroll(function () { if (window.openedwindow && window.openedwindow.isactive() && window.openedwindow.isshow) { if (scrolltimeout) { cleartimeout(scrolltimeout); } scrolltimeout = settimeout(function () { window.openedwindow.center(); }, 100); } }); /* $("span.dnnformbinder").each(function () { var controlid = this.id.split('_')[0]; $("[id*=_" + controlid + "]").after($(this)); });*/ $(document).on("keydown", "input.search", function (e) { if (e.keycode == 13) { var classes = $(this).closest(".dnnmodule").attr("class").split(" "); var mid; if (/dnnmodule-(\d+)/ig.test(classes[classes.length - 1])) { mid = regexp.$1; } if (mid) { var module = globalstech.getmodule(mid); module.setajaxrefreshcommand("serach"); module.refreshmodule(); var that = this; settimeout(function () { that.focus(); }, 500); } return false; } else if (e.keycode == 27) { $("form").get(0).reset(); return false; } return true; }); $(document).on("click", "input[id*=cmddelete]", function () { if (!confirm("是否删除当前数据项?")) { return false; } return true; }); //刷新验证码功能 $(document).on("click", "[data-refresh]", function () { if (this.tagname != "img") { return true; } var url = $(this).attr("src"); var oldurl = $(this).data("url"); if (oldurl) { url = oldurl + "&r=" + math.random(); } else { $(this).data("url", url); url = url + "&r=" + math.random(); } $(this).attr("src", url); }); if (location.href.indexof("popup=true") != -1 && location.href.indexof("dnnprintmode") != -1) { sys.webforms.pagerequestmanager.getinstance().add_beginrequest(function () { $(".dnnactions input[id*=cmdupdate]").prop("disabled", true); }); sys.webforms.pagerequestmanager.getinstance().add_endrequest(function () { $(".dnnactions input[id*=cmdupdate]").prop("disabled", false); }); } // //设置选项卡索引 // var request = globalstech.querystring(location.href); // // settimeout(function () { // if (request["tabindex"]) { // var tabindex = parseint(request["tabindex"]); // $(".ui-tabs-nav li").eq(tabindex).find("a").click(); // } else { // if (!request["id"]) { // $(".ui-tabs-nav li:first a").click(); // } // } // }, 200); globalstechregistervalidator(); }); function globalstechregistervalidator() { if (!$.validator) { settimeout(function () { globalstechregistervalidator(); }, 50); return; } !function () { var a = { 11: "\u5317\u4eac", 12: "\u5929\u6d25", 13: "\u6cb3\u5317", 14: "\u5c71\u897f", 15: "\u5185\u8499\u53e4", 21: "\u8fbd\u5b81", 22: "\u5409\u6797", 23: "\u9ed1\u9f99\u6c5f", 31: "\u4e0a\u6d77", 32: "\u6c5f\u82cf", 33: "\u6d59\u6c5f", 34: "\u5b89\u5fbd", 35: "\u798f\u5efa", 36: "\u6c5f\u897f", 37: "\u5c71\u4e1c", 41: "\u6cb3\u5357", 42: "\u6e56\u5317", 43: "\u6e56\u5357", 44: "\u5e7f\u4e1c", 45: "\u5e7f\u897f", 46: "\u6d77\u5357", 50: "\u91cd\u5e86", 51: "\u56db\u5ddd", 52: "\u8d35\u5dde", 53: "\u4e91\u5357", 54: "\u897f\u85cf", 61: "\u9655\u897f", 62: "\u7518\u8083", 63: "\u9752\u6d77", 64: "\u5b81\u590f", 65: "\u65b0\u7586", 71: "\u53f0\u6e7e", 81: "\u9999\u6e2f", 82: "\u6fb3\u95e8", 91: "\u56fd\u5916" }; checkcard = function (a) { return "number" == typeof a && (a = a.tostring()), "" === a ? !1 : iscardno(a) === !1 ? !1 : checkprovince(a) === !1 ? !1 : checkbirthday(a) === !1 ? !1 : checkparity(a) === !1 ? !1 : !0 }, iscardno = function (a) { var b = /(^\d{15}$)|(^\d{17}(\d|x)$)/; return b.test(a) === !1 ? !1 : !0 }, checkprovince = function (b) { var c = b.substr(0, 2); return void 0 == a[c] ? !1 : !0 }, checkbirthday = function (a) { var b = a.length; if ("15" == b) { var c = /^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/, d = a.match(c), e = d[2], f = d[3], g = d[4], h = new date("19" + e + "/" + f + "/" + g); return verifybirthday("19" + e, f, g, h) } if ("18" == b) { var i = /^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|x)$/, d = a.match(i), e = d[2], f = d[3], g = d[4], h = new date(e + "/" + f + "/" + g); return verifybirthday(e, f, g, h) } return !1 }, verifybirthday = function (a, b, c, d) { var e = new date, f = e.getfullyear(); if (d.getfullyear() == a && d.getmonth() + 1 == b && d.getdate() == c) { var g = f - a; return g >= 3 && 100 >= g ? !0 : !1 } return !1 }, checkparity = function (a) { a = changefivteentoeighteen(a); var b = a.length; if ("18" == b) { var f, g, c = new array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2), d = new array("1", "0", "x", "9", "8", "7", "6", "5", "4", "3", "2"), e = 0; for (f = 0; 17 > f; f++) e += a.substr(f, 1) * c[f]; return g = d[e % 11], g == a.substr(17, 1) ? !0 : !1 } return !1 }, changefivteentoeighteen = function (a) { if ("15" == a.length) { var e, b = new array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2), c = new array("1", "0", "x", "9", "8", "7", "6", "5", "4", "3", "2"), d = 0; for (a = a.substr(0, 6) + "19" + a.substr(6, a.length - 6), e = 0; 17 > e; e++) d += a.substr(e, 1) * b[e]; return a += c[d % 11] } return a }, window.identitycodevalid = checkcard }(); $.validator.addmethod("int", function (value, element) { if (this.optional(element)) { return true; } return /^\d+$/.test(value); }, "无效的格式."); $.validator.addmethod("money", function (value, element) { if (this.optional(element)) { return true; } return /^[0-9]+(.[0-9]+)?$/.test(value); }, "无效金额."); //表达式 $.validator.addmethod("exp", function (value, element, param) { if (this.optional(element)) { return true; } if (typeof param === "string") { param = new regexp(param); } return param.test(value); }, "无效的格式."); //手机号码验证 $.validator.addmethod("mobile", function (value, element) { var mobile = /^1[0-9]{10}$/; return this.optional(element) || mobile.test(value); }, "请正确填写您的手机号码"); //手机号码验证 $.validator.addmethod("tel", function (value, element) { var tel = /^\d{3,4}-?\d{7,9}$/; return this.optional(element) || tel.test(value); }, "请正确填写您的联系电话"); //联系方式 $.validator.addmethod("contact", function (value, element) { return this.optional(element) || /^\d{3,4}-?\d{7,9}$/g.test(value) || /^1\d{10}$/g.test(value); }, "请正确填写您的联系电话"); $.validator.addmethod("idcard", function (value, element) { return this.optional(element) || identitycodevalid(value); }, "无效的身份证号"); // $.validator.addmethod("zipcode", function (value, element) { return this.optional(element) || /^[0-9]{6}$/.test(value); }, "请正确填写您的邮政编码"); $.validator.addmethod("htmlempty", function (value, element) { value = $.trim(unescape(value)); if (value.length == 0) { return false; } value = value.replace(/\r|\n/ig, ""); if (/^\s*(?: )*\s*$/.test(value)) { return false; } return this.optional(element) || (!(/^<([^>]*)>(?:\s*(?: )*\s*)*<\/\1>$/ig.test(value))); }, "编辑器内容不能为空"); // 用户名验证 $.validator.addmethod("username", function (value, element) { return this.optional(element) || /^[\u4e00-\u9fa5a-za-z0-9]{1}$/.test(value); }, "只能包括中文字、英文字母、数字和下划线"); $.validator.addmethod("raddropdown", function (value, element) { var telerikelement = $find(element.id.replace("_clientstate", "")); var selectedvalue = telerikelement.get_selecteditem().get_value(); return (selectedvalue != null && selectedvalue != ""); }, "必须选择"); $.validator.addmethod("dropdown", function (value, element) { return (value != 0 && value != ""); }, "必须选择"); $.validator.addmethod("fileupload", function (value, element) { if ((value && value != "") || $(element).closest(".radasyncupload").find(".uploaded").length > 0) { return true; } return false; }, "必须上传一个文件"); function fixtabs(validator) { var errorelement = $(validator.findlastactive() || validator.errorlist.length && validator.errorlist[0].element || []); if (errorelement.length > 0) { var $parent = $(errorelement).closest(".ui-tabs-panel"); if ($parent.length > 0) { var tabid = $parent.attr("id"); $parent.parent().find("a[href='#" + tabid + "']").click(); } } if (typeof ckeditor != "undefined") { for (var name in ckeditor.instances) { var editor = ckeditor.instances[name]; ckeditor.remove(editor); } ckeditor.replaceall("editor"); } } $.extend($.validator.messages, { required: "必须填写", remote: "请修正此栏位", email: "请输入有效的电子邮件", url: "请输入有效的网址", date: "请输入有效的日期", dateiso: "请输入有效的日期 (yyyy-mm-dd)", number: "请输入正确的数字", digits: "只可输入数字", creditcard: "请输入有效的信用卡号码", equalto: "你的输入不相同", extension: "请输入有效的后缀", maxlength: $.validator.format("最多 {0} 个字"), minlength: $.validator.format("最少 {0} 个字"), rangelength: $.validator.format("请输入长度为 {0} 至 {1} 之间的字串"), range: $.validator.format("请输入 {0} 至 {1} 之间的数值"), max: $.validator.format("请输入不大于 {0} 的数值"), min: $.validator.format("请输入不小于 {0} 的数值") }); var options = globalstech.getvalidatoroptions(); //验证 if (window["sys"]) { sys.application.add_load(function () { var form = $("form"); var validator = form.validate(options); form.submit(function () { fixtabs(validator); }); sys.webforms.pagerequestmanager.getinstance().add_initializerequest(function (sender, args) { var prm = sys.webforms.pagerequestmanager.getinstance(); var element = args.get_postbackelement(); if ($(element).data("causesvalidation") != false) { if (validator.cancelsubmit) { validator.cancelsubmit = false; return true; } if (validator.form()) { if (validator.pendingrequest) { validator.formsubmitted = true; args.set_cancel(true); prm.abortpostback(); return false; } return true; } else { args.set_cancel(true); prm.abortpostback(); validator.focusinvalid(); fixtabs(validator); return false; } } }); }); } else { $("form").validate(options); } //验证指定分组 $(document).on("click", "[data-group]", function () { var group = $(this).data("group"); if (group) { globalstech.setvalidatorgroup(group); } }); } if (window["dnnmoduledragdrop"]) { window["dnnmoduledragdrop"] = function () { //fix bug }; } //设置预览图 if ($.colorbox) { settimeout(function () { $("a.img").colorbox(); }, 500); }