When developers ask how to overcomplicate their regular expressions, I usually recommend that they take a step back and just write some code, and throw in regex for the parts they can formalize well.
You asked how to determine if a string is entirely alpha characters or entirely numbers.
A regex to detect all alphabetic characters is
/^[a-z]*$/i
A regex to detect all numeric characters is
/^\d*$/
Combining them is simply:
function valid(str) { return /^[a-z]*$/i.test(str) || /^\d*$/.test(str); }
Now if you want to combine it all into a single regular expression you just have to use the | regular expression operation:
function valid(str) { return /^[a-z]*$|^\d*$/i.test(str); }
This can of course be simplified if you use a grouping operator:
/^([a-z]*|\d*)$/i
don't simplify it. It's easier to read and easier to reason about regular expressions when they're shorter and match simpler patterns. Use more small regular expressions, rather than fewer longer regular expressions, even if the code could be made shorter. Future you will thank past you for making the code easier to understand.