In my application, there is a method which return values from the server. Format of the value which I am getting is in string.
MESSAGE :
url:'xxxxxx',
date:'xx/xx/xxxx',
time:'xx:xx:xx',
body:"10"
Now in the body, there is an integer value but it is coming in string. There are possibility that instead of number in the string, irrelevant data can also come like float, characters, special symbols inside the string.
body:'157a'
body:'22/2'
body:'/45'
Now my requirement is, as I get the value I have to check whether the data coming in the form of string is the perfect integer or not. That should not be zero, negative, floating values or characters.
For example
format below is acceptable as per my requirement
body:'225'
body:'147'
body:'534'
format below is not acceptable as per my requirement
body:'0'
body:'-145'
body:'22/a'
body:'67,54'
I tried using parseInt() or isNan() but I have checked that if we do
var data = parseInt('76,54');
console.log(data);
that returns 76. But as per my requirement it should not come like that. Is there any way that I can check for the integer into the string which I am getting from the server.