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?