I have a regex
/^([a-zA-Z0-9]+)$/
this just allows only alphanumerics but also if I insert only number(s) or only character(s) then also it accepts it. I want it to work like the field should accept only alphanumeric values but the value must contain at least both 1 character and 1 number.
While the accepted answer is correct, I find this regex a lot easier to read:
This RE will do:
Explanation of RE:
(?:...)
creates an unreferenced group/i
is the ignore-case flag, so thata-z
==a-zA-Z
.