﻿// JScript File

var msg;

function CheckNull(obj)
{
	if(obj.value.replace(/^\s+|\s+$/g,"")=="")
	{
		//√╳
		msg="must be filled";
		return false;
	}
	return true;
}
function CheckLength(obj,length)
{
	if(obj.value.length>length)
	{
		msg="Must be less than "+length+" characters";
		return false;
	}
    return true;
}
function CheckFormat(obj,format)
{
    var reg =new RegExp(format);
	if(!reg.test(obj.value))
	{
		msg="Bad format";
		return false;
	}
    return true;
}
function Check(obj)
{   
	var cNull=obj._null;
	var length=parseInt(obj._length);
	var regExp=obj._regexp;
	if(cNull=="1"&&!CheckNull(obj))
	{
	   alert(msg);
	   return false;
	}
	if(length>0&&!CheckLength(obj,length))
	{
	   alert(msg);
	   return false;
	}	
	if(regExp!=""&&!CheckFormat(obj,regExp))
	{
	   alert(msg);
	   return false;
	}	
    //otips.innerHTML="<font color=\"red\">&nbsp;&nbsp;<b>√</b></font>";
    return true;
}
// for the change of selected value
function makeSelectChange(obj,desid)
{
    var _value=obj.options[obj.selectedIndex].value;
    var _des=document.getElementById(desid);
    _des.value=_value;
}
/*function Check(obj,cNull,cLengh,cFormat,length,format)
{
    var oid=obj.id+"_tips";
	var otips=document.getElementById(oid);
	if(cNull&&!CheckNull(obj,otips))
	{
	   return false;
	}
	if(cLengh&&!CheckLength(obj,otips,length))
	{
	   return false;
	}	
	if(cFormat&&!CheckFormat(obj,otips,format))
	{
	   return false;
	}	
    otips.innerHTML="<font color=\"red\">&nbsp;&nbsp;<b>√</b></font>";
    return true;
}
function Focus(obj)
{
    var oid=obj.id+"_tips";
	var otips=document.getElementById(oid);
	otips.innerHTML="<font color=\"red\">&nbsp;&nbsp;*</font>";
}*/