problem with 'Check to see if a string is numeric function' and fnSetColumnVis api
problem with 'Check to see if a string is numeric function' and fnSetColumnVis api
deng.zz
Posts: 2Questions: 0Answers: 0
1.[code]
function(sData) {
/* Sanity check that we are dealing with a string or quick return for a number */
if (typeof sData == 'number') {
return 'numeric';
}
else if (typeof sData.charAt != 'function') {
return null;
}
var sValidFirstChars = "0123456789-";
var sValidChars = "0123456789.";
var Char;
var bDecimal = false;
/* Check for a valid first char (no period and allow negatives) */
Char = sData.charAt(0);
if (sValidFirstChars.indexOf(Char) == -1) {
return null;
}
/* Check all the other characters are valid */
for (var i = 1; i < sData.length; i++) {
Char = sData.charAt(i);
if (sValidChars.indexOf(Char) == -1) {
return null;
}
/* Only allowed one decimal place... */
if (Char == ".") {
if (bDecimal) {
return null;
}
bDecimal = true;
}
}
return 'numeric';
},
[/code]
this function, if sData is null, it will throw exception.
2.
[code]
oTable.fnSetColumnVis($("#mycheck").val(), true);
[/code]
it doesn't work.i have to use it like this:
[code]
oTable.fnSetColumnVis(Number($("#mycheck").val()), true);
[/code]
thank you!
function(sData) {
/* Sanity check that we are dealing with a string or quick return for a number */
if (typeof sData == 'number') {
return 'numeric';
}
else if (typeof sData.charAt != 'function') {
return null;
}
var sValidFirstChars = "0123456789-";
var sValidChars = "0123456789.";
var Char;
var bDecimal = false;
/* Check for a valid first char (no period and allow negatives) */
Char = sData.charAt(0);
if (sValidFirstChars.indexOf(Char) == -1) {
return null;
}
/* Check all the other characters are valid */
for (var i = 1; i < sData.length; i++) {
Char = sData.charAt(i);
if (sValidChars.indexOf(Char) == -1) {
return null;
}
/* Only allowed one decimal place... */
if (Char == ".") {
if (bDecimal) {
return null;
}
bDecimal = true;
}
}
return 'numeric';
},
[/code]
this function, if sData is null, it will throw exception.
2.
[code]
oTable.fnSetColumnVis($("#mycheck").val(), true);
[/code]
it doesn't work.i have to use it like this:
[code]
oTable.fnSetColumnVis(Number($("#mycheck").val()), true);
[/code]
thank you!
This discussion has been closed.
Replies
Regards,
Allan