日期:2013-09-01  浏览次数:20886 次

var Page_ValidationVer = "125";
var Page_IsValid = true;
var Page_BlockSubmit = false;
var Msg="";
///验证入口
function Page_ClientValidate()
{
var i;
for (i = 0; i < Page_Validators.length; i++) {
if(!ValidatorValidate(Page_Validators[i]))
{
MsgBox(Page_Validators[i]);
event.returnValue = false;
return false;
}
}

}
function MsgBox(val)
{
if(Msg!="")
{
Msg="(错误提示:"+Msg+")";
}
alert(ValidatorErrorMsg(val)+"\r\n"+Msg);
}
///单个验证
function ValidatorValidate(val) {
var control = ValidatorControl(val.controltovalidate);
value=ValidatorGetValue(control);
if(!MaxLength(val.MaxLength,value)) return false;
flag=true;
if(value=="")
{
control.focus();
Msg="文本框不能为空!";
return val.AllowNull=="True";
}
var dataType = val.DataType;
if(dataType=="Empty")
{
flag= true;
}
else if(dataType =="String")
{
flag = IsString(value);
}
else if(dataType =="Letter")
{
flag = IsLetter(value);
}
else if (dataType == "StringInteger") {
flag= IsStringInteger(value);
}
else if (dataType == "Integer") {
flag= IsInteger(value);
}
else if(dataType =="Chinese")
{
flag = IsChinese(value);
}
else if(dataType =="UnSignIntger")
{
flag = IsUnSignIntger(value);
}
else if(dataType == "Double") {
flag = IsDouble(value);
}
else if(dataType =="Email")
{
flag = IsEmail(value);
}
else if(dataType =="IP")
{
flag = IsIP(value);
}
else if(dataType =="Phone")
{
flag = IsPhone(value);
}
else if(dataType =="ZIP")
{
flag = IsZIP(value);
}
else if (dataType == "Currency") {
flag = IsCurrency(value);
}
else if (dataType == "Date") {
flag = IsDate(value);
}
else if(dataType =="Time")
{
flag = IsTime(value);
}
else if (dataType == "DateTime") {
flag = IsDateTime(value);
}
else
{
flag = IsOther(value);
}

if(flag==false)
{
control.focus();
}
return flag;
}
///获取验证的错误消息
function ValidatorErrorMsg(val)
{
return val.errormessage;
}
///获取控件对象
function ValidatorControl(id)
{
var control;
control = document.all[id];
return control
}
function ValidatorGetValue(control) {

if (typeof(control.value) == "string") {
return control.value;
}
if (typeof(control.tagName) == "undefined" && typeof(control.length) == "number") {
var j;
for (j=0; j < control.length; j++) {
var inner = control[j];
if (typeof(inner.value) == "string" && (inner.type != "radio" || inner.status == true)) {
return inner.value;
}
}
}
else {
return ValidatorGetValueRecursive(control);
}
return "";
}
function ValidatorGetValueRecursive(control)
{
if (typeof(control.value) == "string" && (control.type != "radio" || control.status == true)) {
return control.value;
}
var i, val;
for (i = 0; i<control.children.length; i++) {
val = ValidatorGetValueRecursive(control