I knwo little about javascipt and found this code elsewhere and looking to try to tweek.
It works fine in changing the value entered to numbers only but need to allow for a decimal place.
Is it possible to change this code to allow for a . decimal
It works fine in changing the value entered to numbers only but need to allow for a decimal place.
Is it possible to change this code to allow for a . decimal
Code:
function toNumber(checkString)
{
newString = ""; // REVISED/CORRECTED STRING
count = 0; // COUNTER FOR LOOPING THROUGH STRING
// LOOP THROUGH STRING CHARACTER BY CHARACTER
for (i = 0; i < checkString.length; i++) {
ch = checkString.substring(i, i+1);
// ENSURE CHARACTER IS AN NUMBER
if ((ch >= "0" && ch <= "9") || (ch = "")){
newString += ch;
}
}
return newString;
}