window.location.reload(); //当前页面加载
/**
* 验证是否是数字(整数)
* @returns {boolean}
*/
function validateNumberZ(numberString) {
var reg = new RegExp("^[0-9]*$");
if (!reg.test(numberString)) {
return false;
}
return true;
}
/**
* 验证是否是数字(最多2位小数)
* @returns {boolean}
*/
function validateNumber(numberString) {
var reg = new RegExp("^[0-9]+([.]{1}[0-9]{1,2})?$");
if (!reg.test(numberString)) {
return false;
}
return true;
}
function validateNumber0(numberString) {
if (numberString == 0 || numberString == '0')
return true;
var reg = new RegExp("^[0-9]+([.]{1}[0-9]{1,2})?$");
if (!reg.test(numberString)) {
return false;
}
return true;
}
/**
* 显示2位小数,如果小于0.01则显示4位小数
* @param num
* @returns {string|*}
*/
var kakaFixed = function(num) {
if (typeof num != 'number') {
try {
num = new Number(num);
} catch (e) {
console.error(num + ' is not number,kakaFixed');
return;
}
}
if (!num) {
num = 0;
}
return new Number(num.toFixed(6)).valueOf();
};
/**
* 判断是否不为空
* @param obj
* @returns {boolean}
*/
function isNotNull(obj) {
if (obj && obj != undefined && obj != 'undefined' && obj != '') {
return true;
}
return false;
}
function showNumber(number, color) {
if (number || number == 0) {
if (color) {
return '<font color="' + color + '">' + number + '</font>';
} else {
return number;
}
}
return '';
}
/**
* 验证电话(包括手机号和座机)
* @param str
* @returns {*}
*/
var checkPhones = function(str) {
return checkMobile(str) || checkPhone(str);
};
/**
* 验证手机号
* @param str
* @returns {*}
*/
var checkMobile = function(str) {
var is = false;
var re = /^1\d{10}$/;
if (re.test(str)) {
is = true;
} else {
is = false;
}
return is;
};
/**
* 验证座机电话
* @param str
* @returns {*}
*/
var checkPhone = function(str) {
var is = false;
var re = /^0\d{2,3}-?\d{7,8}$/;
if (re.test(str)) {
is = true;
} else {
is = false;
}
return is;
};
/**
* 验证邮箱
* @param str
* @returns {*}
*/
var checkEmail = function(str) {
var is = false;
var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
if (re.test(str)) {
is = true;
} else {
is = false;
}
return is;
};
/**
* 验证邮编
* @param str
* @returns {boolean}
*/
var checkPost = function(str) {
var is = false;
var re = /^[1-9]\d{5}$/;
if (re.test(str)) {
is = true;
} else {
is = false;
}
return is;
};
function getTimeStrBytimes(times) {
var html = '';
if (times) {
if (times > 60) {
html += parseInt(times / 60) + '时'
+ (times % 60 ? times % 60 + '分' : '');
} else {
html += times + '分';
}
}
return html;
}