You are viewing limited content. For full access, please sign in.

Question

Question

isNaN Question

asked on September 21, 2015

I have a Forms process that has the following code in it that I received from somewhere on Answers as an answer to another question:

function parseNumber(n) {
        var f = parseFloat(n); //Convert to float number.
        return isNaN(f) ? 0 : f; //treat invalid input as 0;
    }

If I want to treat invalid input as nothing, what would I change this to?

1 0

Answer

SELECTED ANSWER
replied on September 21, 2015

Use

return isNaN(f) ? '' : f;
0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.