jsUtils.isInt()

Checks if the variable is an integer.

jsUtils.isInt( str )
  str - any javascript variable

Returns true if the variable is a valid integer or false otherwise.

Any input variable is treated as a string. The function will test each charector in this string to be inside the set of 0..9. If all charectors are inside the set, it will return true, otherwise false.

Example

<!DOCTYPE html>
<html>
<head>
    <script src="system/libs/jsUtils.js" type="text/javascript"></script>
    <script type="text/javascript">
        window.onload = function() {
            alert(jsUtils.isInt('10'));
            alert(jsUtils.isInt('10.2'));
        }
    </script>
<body>
</body>
</html>

See Also