I have a JavaScript regular expression that I'm using for frontend password validation in an input field. Here is what my input field looks like:
<input type='password' placeholder='Password...' id='password' pattern='^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})' required>
That regular expression is looking for a string: eight characters or longer, with an uppercase letter, lowercase letter, number, and a special character. Let's take the string: November2017! for instance. That should pass the regular expression, but it doesn't in my webapp. And when I copy and paste the regular expression from my input field ^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,}) and put it into regex101.com, that string passes the validation. But it does not pass the validation in my webapp. Is there a specific reason why putting it in a pattern attribute would change whether or not it would pass validation?
patternrequires to match the complete string. Your pattern does not match the complete string regex101.com/r/WcqXSR/1 It matches the position in the beginning of the string only.