-1

I have found two regex functions. One validates only numbers and the other only spaces.

Sources:

https://stackoverflow.com/a/1731200/3102325

https://stackoverflow.com/a/9011554/3102325

function isNumber(value) {
    var numberRegex = /^\d+$/;
    return numberRegex.test(value);
}

function hasWhiteSpace(str) {
    return /\s/g.test(str);
}

I am looking for a function that returns true if a string contains numbers or spaces. Can you please help?

Marian07
  • 1,892
  • 3
  • 26
  • 46

0 Answers0