how to check if string contains digits from 1 to 8 in javascript code example
Example 1: check if a string contains digits js
function hasNumber(myString) {
return /\d/.test(myString);
}
Example 2: js string have number js
var hasNumber = /\d/;
hasNumber.test("ABC33SDF"); //true
hasNumber.test("ABCSDF"); //false