containsOnlyIntegers
The containsOnlyIntegers function checks if a given string contains only integer digits (0-9). It returns true if the string matches the pattern of one or more digits, otherwise false.
Works in: HTML5, React JS, Node.js
| Parameter | Type | Default | Description |
|---|---|---|---|
str | string | undefined | The string to check for integer digits. |
Usage
Example: Check String for Integers
const str1 = "12345";
const str2 = "123a45";
console.log(nfsfu234FormValidation.containsOnlyIntegers(str1)); // true
console.log(nfsfu234FormValidation.containsOnlyIntegers(str2)); // falseSee also
Last updated on