Date.prototype.format =function(format) {
var o={
"M+":this.getMonth() + 1,
"d+":this.getDate(),
"h+":this.getHours(),
"m+":this.getMinutes(),
"s+":this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S":this.getMilliseconds()
}
if(/(y+)/.test(format)){
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for(vark in o){
if(newRegExp("("+ k +")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? (o[k]) : ("00"+ o[k]).substr((""+ o[k]).length));
}
}
return format;
}
String.prototype.isInt =function() {
var partten =/(^[1-9][0-9]*$)|(^[0-9]$)/;
return partten.test(this);
}
String.prototype.isFloat =function() {
var partten =/(^[1-9][0-9]*[\.]{0,1}[0-9]*[0-9]$)|(^[0].[0-9]*[0-9]$)|(^[0-9]$)/;
return partten.test(this);
}
String.prototype.More =function() {
return this> 0;
}
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,"");
}
String.prototype.isEmpty =function() {
return this.replace(/(\s*$)/g,"") =="";
}
String.prototype.isZip =function() {
var partten =/^\d{6}$/;
return partten.test(this);
}
String.prototype.isPhone =function() {
var partten =/^\d[0-9\-]+\d$/;
return partten.test(this);
}
String.prototype.isMobile =function() {
var partten =/^\d[\d]{9,15}\d$/;
return partten.test(this);
}
String.prototype.isLetterNumber =function() {
var partten =/^[0-9a-zA-Z\-]+$/;
return partten.test(this);
}
String.prototype.isLetterMore =function() {
var partten =/^[0-9a-zA-Z,\-]+$/;
return partten.test(this);
}
String.prototype.isNumber =function() {
var partten =/^[0-9]+$/;
return partten.test(this);
}
String.prototype.isNum =function() {
var partten =/(^[\-[0-9\.]*[0-9]$)|(^[0-9\.]*[0-9]$)/;
return partten.test(this);
}
String.prototype.isBankAccount =function() {
var partten =/^[0-9 ]{19,25}$/;
return partten.test(this);
}
String.prototype.isEmail =function() {
var regu ="^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|com|gov|mil|org|edu|int|name|asia)$";
var re =new RegExp(regu);
if(this.search(re) == -1) {
return false;
}
else{
return true;
}
}
$.fn.selectAll =function(name) {
$(this).click(function() {
var cb = $(this).prop("checked");
$("input[name='"+ name +"']:checkbox").each(function() {
$(this).prop("checked", cb)
});
});
};
$.fn.colorPicker =function(obj) {
$(this).colorpicker({
fillcolor:true,
event:'click',
success:function(o, color) {
$(obj).css("color", color);
$(o).css("color", color);
}
});
};
$.fn.previewShow =function(uri, id, attr, iHeight, iWidth) {
$(this).click(function() {
var url ='';
var infoId ='';
(!uri) ? url = $(this).attr('url') : url = uri;
(!id) ?'': infoId = $(this).attr(attr);
(!iHeight) ? iHeight = 630 :'';
(!iWidth) ? iWidth = 405 :'';
var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
if(!url || url =='') {
$.alert('无法访问,无有效地址!', dialoglist);
return;
}
url += (!infoId) ?'': ('&'+ id +"="+ infoId);
window.open(url,"","top="+ iTop +",left="+ iLeft +",width="+ iWidth +",height="+ iHeight +",menubar=0,scrollbars=1, resizable=1,status=1,titlebar=0,toolbar=0,location=no");
return false;
});
};