//检查有效数据
//代码检测
function isValidCode(stringObj){
var ret = 1 ;
if(stringObj.value=="")return ret ;
var dataPat = /^\S+$/;
var matchArray = stringObj.value.match(dataPat);
if (matchArray == null) ret = 0;
if(!ret){
alert("请输入正确的代码类型:[A-Za-z0-9]!");
stringObj.focus();
stringObj.select();
}
return ret ;
}
function isValidInteger(integerObj){
var ret = true ;
if(integerObj.value=="")return ret ;
var dataPat = /^(\d+)(\.?)$/;
var matchArray = integerObj.value.match(dataPat);
if (matchArray == null) ret = false;
if(!ret){
alert("请输入正确的整型:([0-9]!");
integerObj.focus();
integerObj.select();
}
return ret ;
}
function isValidNumeric(numericObj){
var ret = 1 ;
if(numericObj.value=="")return ret ;
var dataPat = /^(\d+)(\.?)(\d*)$/;
var matchArray = numericObj.value.match(dataPat);
if (matchArray == null) ret = 0;
if(!ret){
alert("请输入正确的数字类型:(xx*.yy*)!");
numericObj.focus();
numericObj.select();
}
return ret ;
}
//
//检查有效日期
function isValidDate(dateObj){
var ret = 1 ;
if(dateObj.value=="") return ret ;
var datePat = /^(\d{4})(\-)(\d{1,2})(\-)(\d{1,2})$/;
var matchArray = dateObj.value.match(datePat);
if (matchArray == null) ret = 0;
if(ret){
//alert(matchArray[1]+'-'+matchArray[3]+'-'+matchArray[5]);
var d= new Date(matchArray[1], matchArray[3],matchArray[5]);
// alert(d.getDate()+'aa'+d.getMonth()+'bb');
if(matchArray[3]==12){
matchArray[3] = 0 ;
matchArray[1] = parseInt(matchArray[1]) + 1;
}
//if(d.getFullYear()!=matchArray[1]) {ret = 0; alert(matchArray[1]); }
//if(ret&&(d.getMonth()!=matchArray[3])){ ret = 0; alert(matchArray[3]); }
//if(ret&&(d.getDate()!=matchArray[5])) {ret = 0; alert(matchArray[5]);}
}
if(!ret){
alert("请输入正确的日期格式:(yyyy-mm-dd)!");
dateObj.focus();
dateObj.select();
return false;
}
return true ;
}
//判断用户已经输入多少个字符
function strlength(str){
var l=str.length;
var n=l
for (var i=0;i<l;i++) {
if (str.charCodeAt(i)<0||str.charCodeAt(i)>255) n++
}
return n
}