function checknull(name,obj)
{
	var datastr = obj.value;
	var lefttrim = datastr.search(/\S/gi);
	if (lefttrim == -1) {
    
      alert("请输入" + name + "！");
      try{obj.focus();obj.select();}catch(e){}
      return false;
  }
  return true;
}
function checkstr(name,obj)
{
	var datastr = obj.value;
	
	if (datastr =="选择省份"||datastr =="选择城市") {
    
      alert("请输入" + name + "！");
      try{obj.focus();obj.select();}catch(e){}
      return false;
  }
  return true;
}


function checkzero(name,obj)
{
	var datastr = obj.value;
	if (datastr==0) {
      alert(name);
      return false;
  }
  return true;
}


function myalert(name,obj)
{
 alert("请输入" + name + "！");
      try{obj.focus();obj.select();}catch(e){}
}
//opt1 小数 opt2 负数 
//当opt2为1时检查num是否是负数 
//当opt1为1时检查num是否是小数 
//返回1是正确的，0是错误的
function chknbr(name,obj,opt1,opt2) 
{ 
var num = obj.value;
var i=num.length; 
var staus; 
//staus用于记录.的个数 
status=0; 
if ((opt2!=1) && (num.charAt(0)=='-')) 
{ 
myalert(name,obj);
return false; 

} 
//当最后一位为.时出错 
if (num.charAt(i-1)=='.') 
{ 
myalert(name,obj);
return false; 
} 

for (j=0;j<i;j++) 
{ 
if (num.charAt(j)=='.') 
{ 
status++; 
} 
if (status>1) 
{ 
myalert(name,obj);
return false; 
} 
if (num.charAt(j)<'0' || num.charAt(j)>'9' ) 
{ 
if (((opt1==0) || (num.charAt(j)!='.')) && (j!=0)) 
{ 
myalert(name,obj);
return false; 
} 
} 
} 
return true; 
} 







function checknum(name,obj)
{
	var datastr = obj.value;
	if (datastr.match(/\D/)!=null) {
      alert(name + "应为数字！");
      try{obj.focus();obj.select();}catch(e){}
      return false;
  }
  return true;
}
function checkdt(name,obj)
{
var datastr = obj.value;
if (datastr!="")
	{
		if(isInvalidDate(datastr,"-")==true){
			alert("请正确填写您的"+name+"（例如:2003-09-20）！");
      try
      {
      obj.select();
      obj.focus();
      }
      catch(e){}
      return false;
		}
		return true;
  }
  return true;
}
function parseNum(theNum){
  if (theNum.substring(0,1)==0)
    theNum=theNum.substring(1)
  return theNum
}
function parseYMD(theYear,theMonth,theDay) {
  theYear=parseNum(theYear)
  theMonth=parseNum(theMonth)
  theDay=parseNum(theDay)
  if ((theYear < 1900) || (theYear > 3000)){
    return 1
  }
  if (theMonth < 1 || theMonth > 12){
    return 2
  }
  if ((theMonth==1 || theMonth==3 || theMonth==5 || theMonth==7 || theMonth==8 || theMonth==10 || theMonth==12) &&
      (theDay <1 || theDay > 31)
     ){
    return 3
  }
  if ((theMonth==4 || theMonth==6 || theMonth==9 || theMonth==11) &&
      (theDay <1 || theDay > 30)
     ){
    return 3
  }
  if (theYear%400==0 || (theYear%4==0 && theYear%100!=0)){  //闰年
    if (theMonth==2 && (theDay <1 || theDay > 29) )
      return 3
  }
  else  //平年
    if (theMonth==2 && (theDay <1 || theDay > 28) )
      return 3
  return 0
}
function isInvalidDate(theDate,separator){
	var datastr = theDate;
  var myRegExp =/[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}/gi;// /[a-z0-9](([a-z0-9]|[_\-\.][a-z0-9])*)@([a-z0-9]([a-z0-9]|[_\-][a-z0-9])*)((\.[a-z0-9]([a-z0-9]|[_\-][a-z0-9])*)*)/gi;
  var answerind = datastr.search(myRegExp);
  var answerarr = datastr.match(myRegExp);
  if (answerind != 0 || answerarr[0].length != datastr.length)
		return true
  default_style=1
  if (theDate.length>10 || theDate.length<8)
    return true
  idx1=theDate.indexOf(separator)
  if (idx1==-1)
    return true
  idx2=theDate.indexOf(separator,idx1+1)
  if (idx2==-1)
    return true
  if (isInvalidDate.arguments.length>2)
  	default_style=isInvalidDate.arguments[2]
  if (default_style<1 || default_style>9){
  	alert("传入参数有误！请检查。")
	return true
  }
  if (default_style==1){
  theYear=theDate.substring(0,idx1)
  theMonth=theDate.substring(idx1+1,idx2)
  theDay=theDate.substring(idx2+1)
  }
  if (default_style==2){
  theMonth=theDate.substring(0,idx1)
  theDay=theDate.substring(idx1+1,idx2)
  theYear=theDate.substring(idx2+1)
  }
  if (theDay.length>2)
    return true
  if (parseYMD(theYear,theMonth,theDay)>0)
    return true
  else
    return false
}
function checklogin(oo)
{return checknull('用户',oo.uname)&&checknull('密码',oo.upwd)&&checknull('验证码',oo.verIfy);}
