function CheckEmpty(Field, FieldTitle) { if (Field.value == "") { alert("请在\"" + FieldTitle + "\"中输入值."); Field.focus(); return false; } return true; } function CheckInteger(Field, FieldTitle) { if (Field.value != "") { for (i = 0; i < Field.value.length; i++) { ch = Field.value.charAt(i); if ( (ch < '0' || ch > '9') && ch != '-' ) { alert("\"" + FieldTitle + "\"中只能输入数字."); Field.focus(); return false; } } } return true; } function CheckReal(Field, FieldTitle) { if (Field.value != "") { DotNum = 0; for (i = 0; i < Field.value.length; i++) { ch = Field.value.charAt(i); if ((ch < '0' || ch > '9') && ch != '.') { alert("\"" + FieldTitle + "\"中只能输入数字."); Field.focus(); return false; } if (ch == '.') { if (DotNum > 0) { alert("\"" + FieldTitle + "\"中只能输入一个小数点."); Field.focus(); DotNum++; return false; } } } } return true; } function CheckMaxLength(Field, MaxLength, FieldTitle) { if (Field.value != "") { if (Field.value.length > MaxLength) { alert("\"" + FieldTitle + "\"中输入的字符请不要超过" + MaxLength + "字符."); Field.focus(); return false; } } return true; } function CheckOption(Field, FieldTitle) { for (i = 0; i < Field.length; i++) if (Field[i].checked) return true; alert("请选择\"" + FieldTitle + "\"中的值."); return false; } //此函数用于判断Email地址是否正确 function CheckEmail(Field) { // there must be >= 1 character before @, so we // start looking at character position 1 // (i.e. second character) var i = 1; var len = Field.value.length; if (len > 50) { window.alert("email地址长度不能超过50位!"); return false; } pos1 = Field.value.indexOf("@"); pos2 = Field.value.indexOf("."); pos3 = Field.value.lastIndexOf("@"); pos4 = Field.value.lastIndexOf("."); //check '@' and '.' is not first or last character if ((pos1 <= 0)||(pos1 == len-1)||(pos2 <= 0)||(pos2 == len-1)) { window.alert("请输入有效的E-mail地址!"); return false; } else { //check @. or .@ if( (pos1 == pos2 - 1) || (pos1 == pos2 + 1) || ( pos1 != pos3 ) //find two @ || ( pos4 < pos3 ) ) //. should behind the '@' { window.alert("请输入有效的E-mail地址!"); return false; } } return true; } function CheckMinLength(Field, MinLength, FieldTitle) { if (Field.value != "") { if (Field.value.length < MinLength) { alert("\"" + FieldTitle + "\"中输入的字符请不要少于" + MinLength + "字符."); Field.focus(); return false; } } return true; } function CheckField(Field, FieldTitle) { if (Field.value != "") { for (i = 0; i < Field.value.length; i++) { var ch2 ch = Field.value.charAt(i); ch2 = Field.value.charCodeAt(i); if(eval(ch2 - 0x80) >= 0) { } else { if ( (ch < '0' || ch > '9') && ch != '-' && ch!='_' &&(ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z') ) { alert("\"" + FieldTitle + "\"中只能输入中文字符、字母和数字或下划线."); Field.focus(); return false; } } } } return true; } function CheckAgain(Field, FieldTitle) { if (Field.value != "") { var temp; pos1 = Field.value.indexOf("@"); temp=Field.value.substring(1,pos1-1); for (i = 0; i < temp.length; i++) { ch = temp.charAt(i); if ( (ch < '0' || ch > '9') && ch != '-' && ch!='_' &&(ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z') ) { alert("\"" + FieldTitle + "\"中只能输入字母和数字或下划线."); Field.focus(); return false; } } } return true; } function ChangeValue(theForm) { var i,bHZ,nLen,name,tempValue; name = theForm.USER.value; nLen = name.length; bHZ = false; tempValue=""; for(i=0;i= 0) { } else { if ( (ch < '0' || ch > '9') && ch!= '-' && ch!='_' &&(ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z') ) { } else { tempValue=tempValue+ch; } } } //if (!bHZ)theForm.EMAIL.value=theForm.USER.value+"@sinoi.com"; // theForm.EMAIL.value=tempValue+"@SINOi.com"; } function CheckDate() { ymd=theForm.date.value.split("-"); month=ymd[1]-1 var Date = new Date(ymd[0],month,ymd[2]); if (Date.getMonth()+1!=ymd[1]||Date.getDate()!=ymd[2]||Date.getFullYear()!=ymd[0]||ymd[0].length!=4) { alert("非法日期,请依【YYYY-MM-DD】格式输入"); theForm.date.focus(); return false; } alert("输入日期:" + theForm.date.value); return true; } function CheckPROVCITY(theForm) { if ((theForm.PROV.value == "山东省") & (theForm.CITY.value == "其它")) { alert("请选择正确的所在城市(山东省)."); return false; } if ((theForm.PROV.value != "山东省") & (theForm.CITY.value != "其它")) { alert("请选择正确的所在城市、地区组合."); return false; } return true; } function CheckZIPLength(theForm) { if ((theForm.ZIP.value.length != 6) & (theForm.ZIP.value.length != 0)) { alert( "如果填写邮政编码,必须是6位数字."); theForm.ZIP.focus(); return false; } return true; } function CheckMail(theForm) { if (!CheckEmpty(theForm.TITLE, "信件标题")) return false; } function CheckTel(theForm) { if (!CheckEmpty(theForm.TEL, "联系方式(电话/手机/传呼)")) return false; } function CheckMess(theForm) { if (!CheckEmpty(theForm.TITLE, "信息标题")) return false; if (!CheckEmpty(theForm.HTTP, "超级连接")) return false; } function CheckAccount(theForm) { if (!CheckEmpty(theForm.USER, "帐号")) return false; if (!CheckMinLength(theForm.USER, 2, "帐号")) return false; if (!CheckMaxLength(theForm.USER, 16, "帐号")) return false; if (!CheckField(theForm.USER, "帐号")) return false; if (!CheckEmpty(theForm.PASS, "密码")) return false; if (!CheckMinLength(theForm.PASS, 4, "密码")) return false; if (!CheckMaxLength(theForm.PASS, 16, "密码")) return false; if (!CheckEmpty(theForm.PASS2, "密码确认")) return false; if (theForm.PASS2.value != theForm.PASS.value) { alert("密码确认与密码内容不一致。"); theForm.PASS2.focus(); return (false); } if (!CheckEmpty(theForm.EMAIL, "E-mail信箱")) return false; if (!CheckAgain(theForm.EMAIL, "E-mail信箱")) return false; if (!CheckEmail(theForm.EMAIL)) return false; if (!CheckPROVCITY(theForm)) return false; if (!CheckInteger(theForm.ZIP, "邮政编码")) return false; if (!CheckZIPLength(theForm)) return false; if (!CheckMaxLength(theForm.CITY2, 30, "地区关键字")) return false; } function CheckAcc(theForm) { if (!CheckEmpty(theForm.R_USER, "帐号")) return false; if (!CheckMinLength(theForm.R_USER, 2, "帐号")) return false; if (!CheckMaxLength(theForm.R_USER, 16, "帐号")) return false; }