How to check for Float value in Netsuite

In Netsuite, if user use simply use parseFloat Method then error comes,
So its better to check using below code ,
This function will check for NaN and if NaN then script will return 0.


function checkFloat(value, number)
{
    if(number){
        if(isNaN(parseFloat(value))) return 0;
    return parseFloat(value);
    }
    if(value == null) return '';
    return value;
}

This method is very useful if we want to use data coming from Saved Search.
Some times values coming as string or .00 .

Thanks

Comments