function eCheckFloat(sn){
    s= sn.value;
    for (var i = 0; i < s.length; i++) {
        ch = s.substring(i, i + 1)
        if (!((ch >= "0" && ch <= "9") || ch=="." || ch==","))
             return false;
        }
   return true;
}

function CheckFloat(theForm){
   for(var i=1; i<CheckFloat.arguments.length; i++)
         if (!eCheckFloat(theForm.elements[CheckFloat.arguments[i]])){
            alert("请输入数字！");
            theForm.elements[CheckFloat.arguments[i]].focus();
            return false;
        }
   return true;
};


function eCheckEMail(sn){
    s= sn.value;
    if (s.indexOf("@") == -1) return false;
    if (s.indexOf(".") == -1) return false;
    at=false;
    dot=false;
    for (var i = 0; i < s.length; i++) {
        ch = s.substring(i, i + 1)
        if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
                || (ch == "@") || (ch == ".") || (ch == "_")
                || (ch == "-") || (ch >= "0" && ch <= "9")) {
                if (ch == "@"){
                  if (at) return false;
                  else at=true;
                }
                if ((ch==".") && at)
                   dot=true;
        }
        else return false;
    }
   return dot;
}

function CheckEMail(theForm){
   for(var i=1; i<CheckEMail.arguments.length; i++)
         if (!eCheckEMail(theForm.elements[CheckEMail.arguments[i]])){
            alert("请输入正确的Email地址！");
            theForm.elements[CheckEMail.arguments[i]].focus();
            return false;
        }
   return true;
}


function eCheckNum(sn){
    s= sn.value;
    for (var i = 0; i < s.length; i++) {
        ch = s.substring(i, i + 1)
        if (!(ch >= "0" && ch <= "9"))
             return false;
        }
   return true;
}
function CheckNum(theForm){
   for(var i=1; i<CheckNum.arguments.length; i++)
         if (!eCheckNum(theForm.elements[CheckNum.arguments[i]])){
            alert("请输入整数！");
            theForm.elements[CheckNum.arguments[i]].focus();
            return false;
        }
   return true;
}

function eCheckAlpha(sn){
    s= sn.value;
    for (var i = 0; i < s.length; i++) {
        ch = s.substring(i, i + 1)
        if (!((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")))
             return false;
        }
   return true;
}

function CheckAlpha(theForm){
   for(var i=1; i<CheckAlpha.arguments.length; i++)
         if (!eCheckAlpha(theForm.elements[CheckAlpha.arguments[i]])){
            alert("不合法的输入！");
            theForm.elements[CheckAlpha.arguments[i]].focus();
            return false;
        }
   return true;
}

function CheckRequiredFields(theForm) {
   for(i=1; i<CheckRequiredFields.arguments.length; i++)
        if(theForm.elements[CheckRequiredFields.arguments[i]].value==""){
            alert("此项不能为空！");
            theForm.elements[CheckRequiredFields.arguments[i]].focus();
            return false;
        }
   return true;
}
