To validate a field that must have both numbers and letters, I could use:
/^([0-9]+[a-zA-Z]+|[a-zA-Z]+[0-9]+)[0-9a-zA-Z]*$/
But I want to additionally accept numeric only strings.
You mean you want at least one number?
You could use look-ahead assertion.
/^(?=.*\d)[a-z\d]*$/i
i got the answer from http://www.javascripter.net/faq/regularexpressionsyntax.htm
well i can do an "or" function inside regx
/^([0-9]|([0-9]+[a-zA-Z]+|[a-zA-Z]+[0-9]+)[0-9a-zA-Z]*)$/;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With