function CheckEmpty2(Field, FieldTitle) { if (Field.value.replace(/\s+/g,"") == "") { alert("请在\"" + FieldTitle + "\"中输入非空值."); Field.focus(); return false; } return true; } 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 CheckMinLength(Field, MinLength, FieldTitle) { if (Field.value != "") { if (Field.value.length < MinLength) { alert("\"" + FieldTitle + "\"中输入的字符请不要少于" + MinLength + "字符."); 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 CheckMustLength(Field, MustLength, FieldTitle) { if (Field.value != "") { if (Field.value.length != MustLength) { alert("\"" + FieldTitle + "\"中输入的值必须是" + MustLength + "位."); Field.focus(); return false; } } return true; } function CheckIntRange(field,prompt,min,max) { if ( ! CheckInteger(field,prompt) ) return false; ival = parseInt(field.value); if ( ival < min || ival > max ) { alert(prompt + " 只能为 " + min + " 到 " + max + " 之间的数"); field.focus(); return false; } return true; } function CheckisIntRange(field,prompt,min,max) { ival = parseInt(field.value); if ( ival > min && ival < max ) { alert(prompt + "不能以数字开头"); field.focus(); return false; } return true; }