javascript - password regex - raw brace is not allowed in regular expression with unicode flag -
i using jquery plugin bootstrap validator real-time frontend validations.
when add pattern/regex validation validate password (any string @ least 8 characters long), following error
unable check
<input pattern='^.*{8,}$'>
because pattern not valid regexp: raw brace not allowed in regular expression unicode flag
the html is
<input pattern="^.*{8,}$" class="form-control" required="required" name="user[password]" id="user_password" type="password">
how should write regex ?
you should use ^.{8,}$
instead.
this regex valid char - 8 times or more.
note allow spaces inside password. if want allow char not space, can use ^[^\s]{8,}$
instead.
your current regex
accept char (
.
) - number of times (*), , accept (the "any char number of times") @ least 8 chars{8,}
(which makes no sense).
Comments
Post a Comment