function IsEmail(str) { var r = /^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/; if (r.test(str)) { return true; } else { return false; }}function IsTel(str) { var s = /^(d{2,4})(-(d{7,8}))$/; if (s.test(str)) { return true; } else { return false; }}function IsMobile(str) { var regu = /^[1][3,5,8][0-9]{9}$/; var re = new RegExp(regu); if (re.test(str)) { return true; } else { return false; }}function IsDecimal(str) { if (str == "") { return false; } if ((/^-?(([1-9]d*)|d)(.d{1,4})?$/).test(str)) { return true; } else { return false; }}function IsInt(str) { if (str == "") { return false; } if (str == "0") { return false; } var type = "^[0-9]*[1-9][0-9]*$"; var re = new RegExp(type); if (str.match(re) == null) { return false; } else { return true; }}function isChinaOrNumbOrLett(s) { //判断是否是汉字、字母、数字组成 var regu = "^[0-9a-zA-Zu4e00-u9fa5]+$"; var re = new RegExp(regu); if (re.test(s)) { return true; } else { return false; }}function LTrim(str) { return str.replace(/^[ tnr]+/g, "");}function RTrim(str) { return str.replace(/[ tnr]+$/g, "");}function Trim(str) { return RTrim(LTrim(str));}/***************把输入的字母转成大写。***************/function input_to_uppercase(obj) { obj.value = obj.value.toUpperCase();}/***************把输入的字母转成小写。* **************/function input_to_lowercase(obj) { obj.value = obj.value.toLowerCase();}/***************实时检测输入框的字数文字最大长度: 20. 还剩: 20.**************/function check_input_Length(which) { var maxChars = 20; if (which.value.length > maxChars) which.value = which.value.substring(0, maxChars); var curr = maxChars - which.value.length; document.getElementById("chLeft").innerHTML = curr.toString();}//将日期转换成"yyyymmdd"格式 第二个参数为返回类型传入'ym':yyyy-mm,'md':mm-dd,默认为'yyyy-mm-dd'function ConvertDateFormatString(strDate, sye) { if (strDate == null || strDate == "" || strDate == "0" || strDate.length < 8) { return (""); } else { try { var ExDate = new Date(strDate.replace(/^(d{4})(d{2})(d{2})$/, "$1/$2/$3")); var yyyy = ExDate.getFullYear(); var mm = ExDate.getMonth() + 1; mm = mm < 10 ? "0" + mm : mm; var dd = ExDate.getDate(); dd = dd < 10 ? "0" + dd : dd; switch (sye) { case "ym": return yyyy + "-" + mm; break; case "md": return mm + "-" + dd; break; default: return yyyy + "-" + mm + "-" + dd; break; } } catch (e) { return ("") } }}/***************设置与获取CookieCookie.write("张三", "xxxxaaxaaa");alert(Cookie.read("张三"));**************/var Cookie = {}Cookie.write = function (key, value) { var d = new Date(); d.setTime(d.getTime() + 1000 * 60 * 60 * 24 * 30); document.cookie = key + "=" + encodeURI(value) + "; expires=" + d.toGMTString();};Cookie.read = function (key) { var arr = document.cookie.match(new RegExp("(^| )" + key + "=([^;]*)(;|$)")); if (arr != null) return decodeURIComponent(arr[2]); return "";};//easyUI confirm function Confirm(msg, control) { $.messager.confirm("确认", msg, function (r) { if (r) { return true; } }); return false;}//gridview bindfunction gridview(objgridview) { //get obj id var gridviewId = "#" + objgridview; //even $(gridviewId + ">tbody tr:even").addClass("NormalColor"); //first $(gridviewId + ">tbody tr:first").removeClass("NormalColor").addClass("HeadColor"); //odd $(gridviewId + ">tbody tr:odd").addClass("AlterColor"); //move and click $(gridviewId + ">tbody tr").slice(1).hover(function () { $(this).addClass("HoverColor"); }, function () { $(this).removeClass("HoverColor"); }); //all check $("#chkAll").click(function () { $(gridviewId + '>tbody >tr >td >input:checkbox').attr('checked', this.checked); }); //check status $(gridviewId + ' >tbody >tr >td >input:checkbox').click(function () { var expr1 = gridviewId + ' >tbody >tr >td >input:checkbox:checked'; var expr2 = gridviewId + ' >tbody >tr >td >input:checkbox'; var selectAll = $(expr1).length == $(expr2).length; $('#chkAll').attr('checked', selectAll); });}//show easyUI loadfunction Load() { $("").css({ display: "block", width: "100%", height: $(window).height() }).appendTo("body"); $(""). ("正在运行,请稍候。。。").appendTo("body").css({ display: "block", left: ($(document.body).outerWidth(true) - 190) / 2, top: ($(window).height() - 45) / 2 });}//display easyUI Loadfunction dispalyLoad() { $(".datagrid-mask").remove(); $(".datagrid-mask-msg").remove();}//show loadingfunction showLoad(tipInfo) { var eTip = document.createElement('div'); eTip.setAttribute('id', 'tipDiv'); eTip.style.position = 'absolute'; eTip.style.display = 'none'; eTip.style.border = 'solid 0px #D1D1D1'; eTip.style.backgroundColor = '#4B981D'; eTip.style.padding = '5px 15px'; eTip.style.top = '10px'; eTip.style.right = '10px'; eTip.style.width = '120px'; eTip.innerHTML = ' ' + tipInfo + ''; try { document.body.appendChild(eTip); } catch (e) { } $("#tipDiv").css("float", "right"); $("#tipDiv").css("z-index", "99"); $('#tipDiv').fadeIn();}//display loadingfunction closeLoad() { $('#tipDiv').fadeOut();}//open JqueryDialogfunction showMyModalDialog(url, width, height, Title) { var now = new Date(); var urlr if (url.indexOf('=') == -1) { urlr = url + "?cach=" + escape(now); } else { urlr = url + "&cach=" + escape(now); } // add zjc if (Title != null) { JqueryDialog.Open(Title, urlr, width, height); } else { JqueryDialog.Open('', urlr, width, height); }}//close JqueryDialogfunction DialogCloseReload(url, info) { alert(info); window.parent.location.href = url; window.parent.JqueryDialog.Close();}//confirm dialog//if(ConfirmDialog('确认删除数据?')){alert('开始删除');}function ConfirmDialog(info) { if (confirm(info)) { return true; } else { return false; }}/*** ajax post提交* @param url* @param param* @param datat 为html,json,text* @param callback回调函数* @return*/function jsonAjax(url, param, datat, callback) { $.ajax({ type: "post", url: url, data: param, dataType: datat, success: callback, error: function () { jQuery.fn.mBox({ message: '恢复失败' }); } });}/* check alertcheckAlert(IsEmail($("#txtEmail").val()), '请输入正确的邮箱地址');*/function checkAlert(fn, info) { if (fn == false) { alert(info); return; }}/* check alert disabledcheckAlert(IsEmail($("#txtEmail").val()), '请输入正确的邮箱地址','btnSubmit');*/function checkAlert(fn, info, objId) { if (fn == false) { alert(info); $("#" + objId).attr("disabled", true); return false; } else { $("#" + objId).attr("disabled", false); return true; }}/* check to messagevar str = "";str += checkString(IsEmail($("#txtEmail").val()), '请输入正确的邮箱地址');str += checkString(IsMobile($("#txtMobile").val()), '请输入正确的手机号码');*/function checkString(fn, info) { if (fn == false) { return info +"n"; } else { return ""; }}