/* 描述:打开指定窗口 */ $.OpenPage = function(html, target) { window.open(html, target); };
/*说明:验证表单元素值是否发生改变 */ $.isFormChanged = function (el, filter) { filter = filter || function (el) { return false; }; var els = el.elements, l = els.length, i = 0, j = 0, el, opts; for (; i < l; ++i, j = 0) { el = els[i]; switch (el.type) { case "text": case "hidden": case "password": case "textarea": if (filter(el)) break; if (el.defaultValue != el.value) return true; break; case "radio": case "checkbox": if (filter(el)) break; if (el.defaultChecked != el.checked) return true; break; case "select-one": j = 1; case "select-multiple": if (filter(el)) break; opts = el.options; for (; j < opts.length; ++j) { if (opts[j].defaultSelected != opts[j].selected) return true; } break; } } return false; };
//替换字符串 String.prototype.Replace = function (oldValue, newValue) { var reg = new RegExp(oldValue, "g"); return this.replace(reg, newValue); }; //去除空格 String.prototype.Trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }; String.prototype.LTrim = function () { return this.replace(/(^\s*)/g, ""); }; String.prototype.RTrim = function () { return this.replace(/(\s*$)/g, ""); }; $.RTim = function (str, sign) { return str.substring(0, str.lastIndexOf(sign)); }; //js的format格式字符串 String.prototype.format = function () { var s = this, i = arguments.length; //获取参数个数 while (i--) { s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]); } return s; };
/* 描述:获取Url参数 */ $.GetQueryString = function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); return r != null ? unescape(r[2]) : ""; };
//Js截取字符串 String.prototype.SubStrings = function (len) { var str = this; var strLength = str.length; if (strLength > len) { str = str.toString().substr(0, len) + "..."; } else { str = str; } return str; };
日期控件:
||\\'%y-%M-%d\\'
,startDate:'1980-01-01',maxDate:'%y-%M-%d'
,startDate:'1980-01-01',dateFmt: 'yyyy-MM-dd',maxDate: '{%y-10}-%M-%d'