3,000,000 => 3000000
2006/01/24 =>20060124
Enter => Tab
LeftTrim
RightTrim
AllTrim
function ParseNumber(str)
{
aNumStr = str.replace(/,/g, "");
ret = parseInt(aNumStr, 10);
if (isNaN(ret)) return 0;
return ret;
}
{
aNumStr = str.replace(/,/g, "");
ret = parseInt(aNumStr, 10);
if (isNaN(ret)) return 0;
return ret;
}
2006/01/24 =>20060124
function IsDateFormat(str)
{
if (str == "") return true;
if (str.length != 8 && str.length != 10) return false;
str = str.replace(/\//g, "");
if (str.length != 8) return false;
year = str.substring(0, 4);
month = str.substring(4, 6) - 1;
date = str.substring(6, 8);
aDate = new Date(year, month, date);
if (isNaN(aDate)) return false;
if (aDate.getFullYear() != year) return false;
if (aDate.getMonth() != month) return false;
if (aDate.getDate() != date) return false;
return true;
}
{
if (str == "") return true;
if (str.length != 8 && str.length != 10) return false;
str = str.replace(/\//g, "");
if (str.length != 8) return false;
year = str.substring(0, 4);
month = str.substring(4, 6) - 1;
date = str.substring(6, 8);
aDate = new Date(year, month, date);
if (isNaN(aDate)) return false;
if (aDate.getFullYear() != year) return false;
if (aDate.getMonth() != month) return false;
if (aDate.getDate() != date) return false;
return true;
}
Enter => Tab
function Enter()
{
if(event.keyCode == 13)
{
event.keyCode = 9;
}
}
{
if(event.keyCode == 13)
{
event.keyCode = 9;
}
}
LeftTrim
function LTrim(str)
{
var whitespace = new String(" \t\n\r");
var s = new String(str);
if (whitespace.indexOf(s.charAt(0)) != -1)
{
var j=0, i = s.length;
while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
{
j++;
}
s = s.substring(j, i);
}
return s;
}
{
var whitespace = new String(" \t\n\r");
var s = new String(str);
if (whitespace.indexOf(s.charAt(0)) != -1)
{
var j=0, i = s.length;
while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
{
j++;
}
s = s.substring(j, i);
}
return s;
}
RightTrim
function RTrim(str)
{
var whitespace = new String(" \t\n\r");
var s = new String(str);
if (whitespace.indexOf(s.charAt(s.length-1)) != -1)
{
var i = s.length - 1;
while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
{
i--;
}
s = s.substring(0, i+1);
}
return s;
}
{
var whitespace = new String(" \t\n\r");
var s = new String(str);
if (whitespace.indexOf(s.charAt(s.length-1)) != -1)
{
var i = s.length - 1;
while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
{
i--;
}
s = s.substring(0, i+1);
}
return s;
}
AllTrim
function Trim(str)
{
if(str.length != 0)
{
return RTrim(LTrim(str));
}
return str;
}
{
if(str.length != 0)
{
return RTrim(LTrim(str));
}
return str;
}