如有问题请指正,谢谢!
/*//通用IE,获取时间,只允许输入8位-分割的日期
function getMyDateTime(myDate) {
//带日期格式的,去掉日期。
if (myDate.length > 10) {
myDate = myDate.substr(0, 10);
}
//日期格式合法,并且为-分割
var arrDate = myDate.split("-");
if (arrDate.length != 3) {
return 0;
}
var datetime = new Date(arrDate[0], arrDate[1], arrDate[2]);
return datetime.getTime();
}//*/
/*输入限制Start*/
function dateCompare(startDate, endDate) {
//日期格式合法,并且为-分割
var arrStart = startDate.split("-");
if (arrStart.length != 3) {
//return '成立日期格式不合法,格式如下(2010-01-01)';
return CnToEn('zdyClrqbhf','成立日期格式不合法,格式如下(2010-01-01)');
}
var starttime = new Date(arrStart[0], (parseInt(arrStart[1]) - 1), arrStart[2]);
var starttimes = starttime.getTime();
var endtimes = endDate;
if (starttimes >= endtimes) {
//return '成立日期早于当前日期,请验证!';
return CnToEn('zdyClrqz','成立日期早于当前日期,请验证!');
} else {
return '';
}
}
function hasSpecialWord(str) {
if (!str) {
return false;
}
//限制输入%*='\
if (-1 != str.indexOf('%') || -1 != str.indexOf('*') || -1 != str.indexOf('=') || -1 != str.indexOf('\'') || -1 != str.indexOf('\\')) {
return true;
} else {
return false;
}
}
//包含汉字
function chineseWord(str) {
//汉字开头
//var reg = /^[\u4e00-\u9fa5]/;
//包含汉字
var reg = /[\u4e00-\u9fa5]/;
return reg.test(str);
}
//判断是否为空,为空则返回true
function testNull(str) {
if (str == null) {
return true;
} else if (str.replace(/(^\s*)|(\s*$)/g, '').length <= 0) { //为空
return true;
} else { //不为空
return false;
}
}
//判断是否为数字,是数字则返回true
function testNumber(str) {
if (!testNull(str)) {
for (i = 0; i < str.length; i++) {
if (str.charAt(i) < "0" || str.charAt(i) > "9") {
return false;
}
}
return true;
} else {
return true;
}
}
//判断邮政编码格式,格式正确返回true
function testZip(str) {
if (!testNull(str)) {
if (str.length != 6) {
return false;
} else {
var rexTel = /^[0-9]+$/;
if (!rexTel.test(str)) {
return false;
}
}
}
return true;
}
//判断联系电话、传真格式,格式正确返回true
function testPhoneNumber(str) {
if (!testNull(str)) {
var reg = /(^[0-9]{3,4}\-[0-9]{7,8}\-[0-9]{3,4}$)|(^[0-9]{3,4}\-[0-9]{7,8}$)|(^[0-9]{7,8}\-[0-9]{3,4}$)|(^[0-9]{7,15}$)/;
if (!reg.test(str)) {
return false;
}
return true;
} else {
return true;
}
}
//判断电子邮箱格式,格式正确返回true
function testEmail(str) {
if (!testNull(str)) {
if (str.search(/^([-_A-Za-z0-9\.]+)@([-_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/) != -1) {
return true;
} else {
return false;
}
} else {
return true;
}
}
//判断是否是数字,可以为小数,格式正确返回true
function testDoubleNumber(str) {
var pointCount = 0;
for (var i = 0; i < str.length; i++) {
if ((str.charAt(i) < '0' || str.charAt(i) > '9') && str.charAt(i) != '.') {
return false;
} else {
if (str.charAt(i) == '.') pointCount++;
}
}
if (pointCount > 1) {
return false;
} else if (pointCount == 1 && str.length == 1) {
return false;
}
return true;
}
function trim(str) {
if (str == null) { //判断是否为空
return "";
} else {
return str.replace(/(^\s*)|(\s*$)/g, "");
}
}
/*输入限制End************************************************************************/
/*数字转换成大写Start*/
function creatNo(v) {
var test1 = v;
var money1 = new Number(test1);
if (money1 > 1000000000000000000) {
//$.messager.alert('提示', "您输入的数字太大,重新输入!");
$.messager.alert(CnToEn('zdyTs','提示'), CnToEn('zdySztd','您输入的数字太大,重新输入!'));
return;
}
var monee = Math.round(money1 * 100).toString(10)
var i, j;
j = 0;
var leng = monee.length;
var monval = "";
for (i = 0; i < leng; i++) {
monval = monval + to_upper(monee.charAt(i)) + to_mon(leng - i - 1);
}
return repace_acc(monval);
}
function to_upper(a) {
switch (a) {
case '0':
return '零';
break;
case '1':
return '壹';
break;
case '2':
return '贰';
break;
case '3':
return '叁';
break;
case '4':
return '肆';
break;
case '5':
return '伍';
break;
case '6':
return '陆';
break;
case '7':
return '柒';
break;
case '8':
return '捌';
break;
case '9':
return '玖';
break;
default:
return '';
}
}
function to_mon(a) {
if (a > 10) {
a = a - 8;
return (to_mon(a));
}
switch (a) {
case 0:
return '分';
break;
case 1:
return '角';
break;
case 2:
return '元';
break;
case 3:
return '拾';
break;
case 4:
return '佰';
break;
case 5:
return '仟';
break;
case 6:
return '万';
break;
case 7:
return '拾';
break;
case 8:
return '佰';
break;
case 9:
return '仟';
break;
case 10:
return '亿';
break;
}
}
function repace_acc(Money) {
Money = Money.replace("零分", "");
Money = Money.replace("零角", "零");
var yy;
var outmoney;
outmoney = Money;
yy = 0;
while (true) {
var lett = outmoney.length;
outmoney = outmoney.replace("零元", "元");
outmoney = outmoney.replace("零万", "万");
outmoney = outmoney.replace("零亿", "亿");
outmoney = outmoney.replace("零仟", "零");
outmoney = outmoney.replace("零佰", "零");
outmoney = outmoney.replace("零零", "零");
outmoney = outmoney.replace("零拾", "零");
outmoney = outmoney.replace("亿万", "亿零");
outmoney = outmoney.replace("万仟", "万零");
outmoney = outmoney.replace("仟佰", "仟零");
yy = outmoney.length;
if (yy == lett) break;
}
yy = outmoney.length;
if (outmoney.charAt(yy - 1) == '零') {
outmoney = outmoney.substring(0, yy - 1);
}
yy = outmoney.length;
if (outmoney.charAt(yy - 1) == '元') {
outmoney = outmoney + '整';
}
return outmoney;
}
/*数字转换成大写End*/