GabCas
GabCas

Reputation: 788

Compare int to NaN

Using Titanium, is there a way to compare a TextField's value to NaN (not a number)?

For example:

if (parseInt($.myTextField.value) == NaN)  

In this example, it doesn't enter the if statement. I've also tried with '===' to no success.

If I log the value converted to int it says "NaN"

Ti.API.info(parseInt($.myTextField.value));

Your input is appreciated!

Upvotes: 1

Views: 1453

Answers (1)

djechlin
djechlin

Reputation: 60818

Use isNaN native JS function. === to NaN will always be falsy.

Upvotes: 4

Related Questions