I have a password <input>
box in a <form>
element my html body
When a user click on the submit button in the sign up form, I can get javascript to determine whether the string the user typed in the password box is a combination of alphabet and/ or numbers by using the following code
$("#password1").val().match(new RegExp(/[a-zA-Z1-9]{1,}/));
However when I tried using the expression below, it returns "null" which gives me the impression that POSIX expressions are not supported in javascript... or is it somewhere along the line I am missing something?
$("#password1").val().match(new RegExp(/[[:alnum:]]{1,}/));
I have a password <input>
box in a <form>
element my html body
When a user click on the submit button in the sign up form, I can get javascript to determine whether the string the user typed in the password box is a combination of alphabet and/ or numbers by using the following code
$("#password1").val().match(new RegExp(/[a-zA-Z1-9]{1,}/));
However when I tried using the expression below, it returns "null" which gives me the impression that POSIX expressions are not supported in javascript... or is it somewhere along the line I am missing something?
$("#password1").val().match(new RegExp(/[[:alnum:]]{1,}/));
Share
Improve this question
asked Jul 7, 2015 at 23:07
repzerorepzero
8,4123 gold badges20 silver badges42 bronze badges
0
2 Answers
Reset to default 14Posix expressions such as :alnum:
are not supported, though some other backslash-escaped character classes (like \w
for word characters including alphanumeric characters and the underscore) are allowed.
POSIX character classes are not supported, but you can find JavaScript equivalents to them here:
http://www.regular-expressions.info/posixbrackets.html