function Jtrim(str)
{
var i = 0;
var len = str.length;
if ( str == "" ) return( str );
j = len -1;
flagbegin = true;
flagend = true;
while ( flagbegin == true && i< len)
{
if ( str.charAt(i) == " " )
{
i=i+1;
flagbegin=true;
}
else
{
flagbegin=false;
}
}
while(flagend== true && j>=0)
{
if (str.charAt(j)==" ")
{
j=j-1;
flagend=true;
}
else
{
flagend=false;
}
}
if ( i > j ) return ("")
trimstr = str.substring(i,j+1);
return trimstr;
}
function CheckMaxLength(tbName,iMax)
{
var txtName = Jtrim(document.all[tbName].value);
var j=0;
for(i=0;i<txtName.length;i++)
{
if((txtName.charCodeAt(i)>=0) && (txtName.charCodeAt(i)<=255))
{
j=j+1;
}
else
{
j=j+2
}
}
if(j>iMax)
{
return true;
}
return false;
}
function IsValid(tbName,type)
{
var txtName = Jtrim(document.all[tbName].value);
var patrn;
switch(type)
{
case "Email":
patrn = /^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$/;
break;
case "UserName":
patrn = /^[a-zA-Z]{1}([0-9a-zA-Z]|[_.]){5,19}$/;
break;
case "Password":
//patrn = /^[*]{6,20}$/;
patrn = /^([0-9a-zA-Z]|[_.]){6,20}$/;
break;
case "Mobile":
patrn = /^/d{11}$/;
break;
case "WebSite":
patrn = /^http:////([/w-]+/.)+[/w-]+(//[/w- .//?%&=]*)?$/;
break;
case "Int":
patrn = /^[1-9]{1}[0-9]{0,6}$/;
break;
case "Date":
patrn = /^/d{4}-/d{2}-/d{2}$/;
break;
case "Zone":
patrn = /^/d{3,4}$/;
break;
case "Tel":
patrn = /^/d{7,8}$/;
break;
case "Int":
patrn = /^[1-9]{1}[0-9]{0,6}$/;
break;
case "Date":
patrn = /^/d{4}-/d{2}-/d{2}$/;
break;
}
if(!patrn.test(txtName))
{
return true;
}
else
{
return false;
}
}
function SetDefaultOption(oSubSlt,defaultvalue)
{
var i = document.all(oSubSlt).options.length;
//alert(defaultvalue);
for(j=0;j<i;j++)
{
//alert(document.all(oSubSlt).options[j].value);
if(defaultvalue==document.all(oSubSlt).options[j].value)
{
document.all(oSubSlt).options[j].selected = true;
}
}
}
function SetDefaultOption(oSubSlt,defaultvalue)
{
var i = document.all(oSubSlt).options.length;
//alert(defaultvalue);
for(j=0;j<i;j++)
{
//alert(document.all(oSubSlt).options[j].value);
if(defaultvalue==document.all(oSubSlt).options[j].value)
{
document.all(oSubSlt).options[j].selected = true;
}
}
}