/**********************************************/
/*Function List
/*
/*1. trim(inputvalue)
/*2. isNull(inputvalue) true: Yes false: No
/*3. isSize(inputStr,Size) true:Yes false: No
/*4. isInteger(inputvalue) true:Yes false: No
/*5. isNumber(inputvalue) true:Yes false: No
/*6. isInRange(inputval,num1,num2) true:Yes false: No
/*7. isPIN(inputval) true:Yes false: No
/*8. isEML(inputval) true:Yes false: No
/*9. dateCheck(inputval) true:Yes false: No
/*10. noInputString(checknumber) true:Yes false: No
/*11. isBigSize(inputStr,DBSize) true:Yes false: No
/*12. isAllNumber(checknumber) true:Yes false: No
/*13. isEnglishAndNum(checknumber) true:Yes false: No
/*14. isDouble(inputName,inputNum,intSize,decSize) true:Yes
/*15. isInteger1_0(inputvalue) true:Yes false: No
/*16. isPhone(inputvalue) true:Yes false: No
/*17. isLargerStartDateThanEndDate(startDate,endDate) true:Yes false: No add by zhangy 20070807
/*18. isLegalityForLeapYear(inputDate) true:Yes false: No add by zhangy 20070810
/*19. isPinyin(inputPinyin) true:Yes false: No add by zhangy 20070813
/*20. isLoginID(inputLoginID) true:Yes false: No add by zhangy 20070813
/*How to Use <script src = "/jslib/JavaScript.js"></script>
/***********************************************/
function trim(inputVal)
{
inputStr = inputVal.toString();
while ((inputStr.charAt(inputStr.length - 1) == " ") || (inputStr.charAt(0)== " "))
{
if (inputStr.charAt(inputStr.length - 1) == " ")
{
inputStr = inputStr.substring(0,inputStr.length - 1);
}
if (inputStr.charAt(0) == " ")
{
inputStr = inputStr.substring(1,inputStr.length);
}
}
return inputStr;
}
function isNull(inputStr)
{
if (inputStr == null || inputStr == "")
{
return true;
}
return false;
}
function isSize(inputStr, size)
{
if (inputStr.length == size)
return true;
else
return false;
}
function isInteger(inputVal)
{
inputStr = inputVal.toString()
for (var i = 0; i < inputStr.length; i++)
{
var oneChar = inputStr.charAt(i);
//・ク・コ・暮飴・ア
if (i == 0 && oneChar == "-")
{
continue;
}
if (oneChar < "0" || oneChar > "9")
{
return false;
}
}
return true;
}
function isNumber(inputVal)
{
oneDecimal = false;
inputStr = inputVal.toString();
for (var i = 0; i < inputStr.length; i++)
{
var oneChar = inputStr.charAt(i);
if (i == 0 && oneChar == "-")
{
continue;
}
if (oneChar == "." && !oneDecimal)
{
oneDecimal = true;
continue;
}
if (oneChar < "0" || oneChar > "9")
{
return false;
}
}
return true;
}
function isInIntRange(inputVal, num1, num2)
{
var i = parseInt(inputVal);
return((i >= num1) && (i <= num2));
}
function isInRange(inputVal, num1, num2)
{
return((inputVal >= num1) && (inputVal <= num2));
}
function isPIN(inputVal)
{
inputStr = inputVal.toString()
if (inputStr.length != 15 && inputStr.length != 18)
{
return false;
}
for (var i = 0; i < inputStr.length; i++)
{
var oneChar = inputStr.charAt(i);
if (oneChar < "0" || oneChar > "9"){
return false;
}
}
return true;
}
function isEML(inputVal)
{
inputStr = inputVal.toString()
if (inputStr.length < 6 || inputStr.length > 60)
{
return false;
}
if (inputStr.charAt(0) == "@" || inputStr.charAt(0) == ".")
{
return false;
}
if (inputStr.charAt(inputStr.length -1) == "@" ||inputStr.charAt(inputStr.length -1) == ".")
{
return false;
}
if (inputStr.indexOf("@") == -1 || inputStr.indexOf(".") == -1)
{
return false;
}
return true;
}
function dateCheck(dateValue)
{
if(dateValue==null||trim(dateValue)=="") return true;
if (dateValue.length>10) return false;
var re =//b((19|20)/d{2})[/-](1[0-2]|0[1-9])[/-]([12][0-9]|3[01]|0[1-9])/
var result = re.exec(dateValue);
//var re2 =//b((19|20)/d{2})[/-](1[1-2]|[1-9])[/-]([12][1-9]|3[01]|[1-9])/
//var result2 = re2.exec(dateValue);
if(result==null)
{
return false ;
}
else
{
return true;
}
}
function noInputString(checknumber)
{
var checkok="<!'";
var checkstr=checknumber;
var allvalid=true;
for (i=0;i<checkstr.length;i++)
{
ch=checkstr.charAt(i);
for (j=0;j<checkok.length;j++)
if (ch==checkok.charAt(j))
{
allvalid=false;
break;
}
}
if (allvalid==false)
return (true);
}
function isBigSize(inputStr,DBSize)
{
var leng = 0;
for (i=0; i<inputStr.length; i++)
{
if(inputStr.charCodeAt(i)<256)
leng = leng + 1;
else
leng = leng + 2;
}
if (leng > DBSize)
{
return (true);
}
return (false);
}
function isAllNumber(checknumber)
{
var checkok="1234567890";
var checkstr=checknumber;
var allvalid=true;
for (i=0;i<checkstr.length;i++)
{
ch=checkstr.charAt(i);
for (j=0;j<checkok.length;j++)
if (ch==checkok.charAt(j))
break;
if (j==checkok.length)
{
allvalid=false;
break;
}
}
if (allvalid==false)
return (false);
}
function isEnglishAndNum(checknumber)
{
var checkok="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-, ";
var checkstr=checknumber;
var allvalid=true;
for (i=0;i<checkstr.length;i++)
{
ch=checkstr.charAt(i);
for (j=0;j<checkok.length;j++)
if (ch==checkok.charAt(j))
break;
if (j==checkok.length)
{
allvalid=false;
break;
}
}
if (allvalid==false)
return (false);
}
function isDouble(inputNum,intSize,decSize)
{
var blnTrue = true;
blnTrue = isNumber(inputNum);
if(blnTrue == false)
{
return false;
}
if(parseFloat(inputNum) < 0)
{
return false;
}
var intPos = 0;
intPos = inputNum.indexOf(".");
if(intPos == -1)
{
if(inputNum.length > intSize)
{
return false;
}
}
else
{
if(intPos > intSize)
{
return false;
}
else
{
if((inputNum.length - intPos-1) > decSize)
{
return false;
}
}
}
return true;
}
function isInteger1_0(inputVal) {
inputStr = inputVal.toString()
for (var i = 0; i < inputStr.length; i++)
{
var oneChar = inputStr.charAt(i);
// - integer
//if (i == 0 && oneChar == "-") {
//continue;
//}
if (oneChar < "0" || oneChar > "9")
{
return false;
}
}
return true;
}
function isPhone(checknumber)
{
var checkok="1234567890()-";
var checkstr=checknumber;
var allvalid=true;
for (i=0;i<checkstr.length;i++)
{
ch=checkstr.charAt(i);
for (j=0;j<checkok.length;j++)
if (ch==checkok.charAt(j))
break;
if (j==checkok.length)
{
allvalid=false;
break;
}
}
if (allvalid==false)
return (false);
else
return true;
}
function selected(formname)
{
var flag = 0;
for (var i = 0;i<formname.elements.length;i++)
{
var checkObj = formname.elements[i];
if (checkObj.checked)
{
flag = 1;
return true;
}
}
if (flag == 0)
return false;
}
function selectoption(formname,selectname)
{
var flag = 0;
for (var i = 0;i<formname.elements.length;i++)
{
var checkObj = formname.elements(selectname,i);
if (checkObj.value == "0")
{
return false;
}
}
}
/*17 short date dateformat="month/day/year" */
function isLargerStartDateThanEndDate(startDate,endDate)
{
var dayStart,dayEnd;
dayStart=Date.parse(startDate);
dayEnd=Date.parse(endDate);
if(dayStart>dayEnd)
{
return true;
}
else
{
return false;
}
}
/*18 dateformat yyyy/mm/dd */
function isLegalityForLeapYear(inputDate)
{
var checkedDate=trim(inputDate);
var ar,valaid;
valaid=true;
if(isNull(checkedDate))
return valaid;
ar=checkedDate.split("/");
if (((ar[0]% 4==0)&&(ar[0] % 100!=0))|| (ar[0] % 400==0))
{
}
else
{
if((ar[1]=="2")||(ar[1]=="02"))
{
if(ar[2]=="29")
valaid=false;
else
valaid=true;
}
}
return valaid;
}
/*19 pin yin check */
function isPinyin(inputPinyin)
{
var i,j;
var checkok="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
var checkstr=inputPinyin;
var allvalid=true;
allvalid= isNull(checkstr);
if(allvalid)
return (allvalid);
allvalid=true;
for (i=0;i<checkstr.length;i++)
{
ch=checkstr.charAt(i);
for (j=0;j<checkok.length;j++)
if (ch==checkok.charAt(j))
break;
if (j==checkok.length)
{
allvalid=false;
break;
}
}
return (allvalid);
}
/*19 loginID check */
function isLoginID(inputLoginID)
{
var i,j;
var checkok="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
var checkstr=trim(inputLoginID);
var allvalid=true;
allvalid=isNull(checkstr);
if(allvalid)
return allvalid;
allvalid=true;
for (i=0;i<checkstr.length;i++)
{
ch=checkstr.charAt(i);
for (j=0;j<checkok.length;j++)
{
if (ch==checkok.charAt(j))
break;
}
if (j==checkok.length)
{
allvalid=false;
break;
}
}
return (allvalid);
}