Why not first apply the whole test, and then add individual tests for characters and numbers? Anyway, if you want to do it all in one regexp, use positive lookahead:
/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/
More Related Contents:
- What’s the best way to validate an email address in JavaScript?
- Including a hyphen in a regex character bracket?
- How to test valid UUID/GUID?
- Regular expression for URL validation (in JavaScript)
- Validating user’s UTF-8 name in Javascript
- Javascript regular expression to validate URL
- javascript regex for password containing at least 8 characters, 1 number, 1 upper and 1 lowercase [duplicate]
- Validate phone number using javascript
- Example of a regular expression for phone numbers
- Remove text between two parenthesis, if two more parenthesis [closed]
- Need Pattern for password field?
- Regular expression to get a string between two strings in Javascript
- Validate phone number with JavaScript
- Detect URLs in text with JavaScript
- Regular Expression to get a string between parentheses in Javascript
- Check whether a string matches a regex in JS
- Split a string by commas but ignore commas within double-quotes using Javascript
- Matching a Forward Slash with a regex
- How to find a number in a string using JavaScript?
- How can I concatenate regex literals in JavaScript?
- escaping question mark in regex javascript
- Javascript regex (negative) lookbehind not working in firefox
- JavaScript/regex: Remove text between parentheses
- Enable/Disable submit button if checkbox is checked/unchecked?
- How to prevent invalid characters from being typed into input fields
- How to convert “camelCase” to “Camel Case”?
- jquery only allow input float number
- What’s the correct regex range for javascript’s regexes to match all the non word characters in any script?
- Extract keyword from Google search in Javascript
- Regex matching emoticons