Forum Discussion

sean_ng's avatar
sean_ng
Occasional Contributor
6 years ago
Solved

How to check if a string is a number

[ jscript ] i would like to check if the string i obtain is number or alphabets, something like   if numeric(stringABC) then // do something   else // show error   how to write this i...
  • sean_ng's avatar
    sean_ng
    6 years ago

    hi Shankar_r,

     

    thank you for your reply,

    i was lost and don't know how to start writing the code but your code help me to kick start writing, i will keep your code for future reference, thanks a lot.

     

    This is what i manage to come up with :

     

    var ABC = 123;

    if(isNaN(ABC)) { Log.Message(ABC + " is not a number"); } else { Log.Message(ABC + " is a number"); }

     

    this code work well without any problem for me, i am not sure if this is the correct code for test complete because NaN is what i get from jscript, hopefully it won't cause any bug in future, haha ..