Skip to Content
NFSFU234FormValidation v3 is here — file upload validation, config-driven rules, and more.
v2 (legacy)containsOnlyIntegers

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

ParameterTypeDefaultDescription
strstringundefinedThe 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)); // false

See also

Last updated on