check if string only contains integer digits numbers javascript
snippet in javascript

check if string only contains integer digits numbers javascript

user8688

let val = '1234567890' 
let isnum = /^\d+$/.test(val);
if (isnum) {
  // val is a number
}

check if a string contains digits js

user8868

function hasNumber(myString) {
  return /\d/.test(myString);
}