The user needs to enter a number between 0 and 9999 in a text box and I want to check if this string is valid integer number between 0 and 9999. If the user enters more than one number in the text box like for example 16 and 1 then the verification should return false.

I have an issue if there is a "." in the string. 1.11 returns true but it should return false and .111 changes into 0.111 and returns true instead of false. I want that a string with a "." returns false. How can I do that?

I have tested the following cases:

```
0 returns true
1117 returns true
9999 returns true
17000 returns false
0,1 returns false
A1 returns false
16 1 returns false
16_1 returns false
1.11 returns true but it should return false
.111 returns true but it should return false

```

**1.11 and .111 are not working correctly because they return true instead of false.**

What is wrong with the code?

```
handlers.CheckTextboxstring = function (args, context)
{
  var TextboxNumber = validate(args.Textboxstring);
  return TextboxNumber.NewNumber;
}

function validate(str)
{
    if(!isEmptyOrSpaces(str))
    {
      let num=Number(str);
      if(num!==NaN)
      {
         if(num >= 0 && num <= 9999)
         {
           return{NewNumber: "true, number is in range."};
         }
         else
         {
            return{NewNumber: "false, number not in range."};
         }
      }
      else
      {
          return{NewNumber: "false, string is NaN."};
      }
    }
    else
    {
        return{NewNumber: "false, the string is not a number."};
    }
}

function isEmptyOrSpaces(str)
{
    return str === null || str.match(/^ *$/) !== null;
}

```