parsley.js regex not working -
i've created regex using regexr , works there. pattern is:
data-parsley-pattern="/[1|2|3|4|5|i|l|i|l][a-k|m-n|p-z|a-k|m-n|p-z][a-k|m-n|p-z|a-k|m-n|p-z][a-k|m-n|p-z|a-k|m-n|p-z][a-k|m-n|p-z|a-k|m-n|p-z][a-k|m-n|p-z|a-k|m-n|p-z]"
i'm trying limit submissions numbers 1-5 (but accepting "i" , "l") , 5 letters (excluding "l" , "o"). case-insensitive.
the expression works correctly, not parsley pattern.
any idea i'm doing wrong?
you aren't writing regex correctly.
you'd need change pattern to:
data-parsley-pattern="[1-5ilil][a-km-np-za-km-np-z][a-km-np-za-km-np-z][a-km-np-za-km-np-z][a-km-np-za-km-np-z][a-km-np-za-km-np-z]"
and can shortcut using {}
data-parsley-pattern="[1-5ilil][a-km-np-za-km-np-z]{5}"
if want allow 1 5 times class can use:
data-parsley-pattern="[1-5ilil][a-km-np-za-km-np-z]{1,5}"
btw, if want ensure /
present, need add , beginning of regex. i've removed since though typo.
the pipe | used separate patterns instance worda|wordb
match worda or wordb. separating characters inside class []
. class allows chose characters allowed, instance [abpu] match 1 character a, b, p or u.
Comments
Post a Comment