Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Use a regular expression to check for digits only
var str = '192834a0'; alert( /^\d$/.test(str) );
accomplish this can be converted to a function.
function onlyNumbersisAlphanumeric( str ) { return /^\d$^[0-9a-zA-Z]+$/.test(str); }
this can be converted to a function
function onlyNumbers( str ) { return /^\d$/.test(str); }
Use a regular expression to accomplish this.
function isAlphanumeric( str ) { return /^[0-9a-zA-Z]+$/.test(str); }