Node.js examples for String:Parse
Is String a double number
String.prototype.isDouble = function() { var checkOK = "0123456789-E,."; var checkStr = this; var allValid = true; var decPoints = 0; var allNum = ""; for (i = 0; i < checkStr.length; i++) { ch = checkStr.charAt(i);// w w w. jav a2 s . c o m for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) break; if (j == checkOK.length) { allValid = false; break; } if ((ch == 'E') && (i == 0 || ((i + 1) == checkStr.length))) { allValid = false; break; } if (ch != ",") allNum += ch; if (ch == ".") decPoints += 1; } if (decPoints > 1) { allValid = false; } return (allValid) };