Saturday, November 18, 2017

JavaScript Function to get a Valid Number from String


Here is the function to get a numeric value from a string value.


    function GetValidNumberValue(inValue)
   {
        if (inValue == null) return 0.0;
        if (inValue == undefined) return 0.0;
        if (isNaN(inValue) == true) return 0.0;
        let togoNumber = parseFloat(inValue);
        if (isNaN(togoNumber) == true) return 0.0;
        return togoNumber;
    }

No comments:

Post a Comment

All Blogs so far ...