The regular expression pattern used for checking numbers is ^[0-9]+$.
return /^[0-9]+$/.test(data);
[Explanation]
^[0-9]+$
^
Matches the beginning of the string
[0-9]
Matches any character between 0 and 9
+
Matches a string where the previous character is repeated one or more times
$
Matches the end of the string
test()
A method of the regular expression object that checks whether a specified string matches the regular expression pattern. If it matches, it returns true, otherwise it returns false. When checking the result of the test method of a regular expression, use === (strict equality operator). Even with == (equality operator), true and true, and false and false can be compared correctly, but because it involves type conversion, it may result in unintended results.
[Other] Example of checking only half-width numbers and only , (commas) in javascript copy
function test(data) {
//Regular expression to check if the string contains only half-width numbers and commas
const regex = /^[\d,]+$/;
return regex.test(data);
}