I need to validate whether a input is a valid integer allowing for +/- entries.
I have tried this.
function valid(elem)
{
var num = parseInt(elem);
if(!Number.isInteger(num))
{
alert ("Not an integer");
}
}
But the issue here is , it is validating even strings like 10sd
as an integer. So how to validate this?
I want to validate as following:
valid(-10) = true;
valid(+10) = true;
valid(-10.01) = false;
valid(10sd) = false;
valid(10.23see) = false;
valid(10) = true;