AddRule Pattern ignoring input

jdan1131x
Member | 41
+
0
-

problem:
$form->addText(‘username’,‘Username:’,20,50) //col/len
->setRequired(‘Please enter user name’)
->addRule($form::MIN_LENGTH, “Names must be at least %d characters”,6)
->addRule($form::MAX_LENGTH, “Max name length exceeded”,50)
->addRule($form::PATTERN,“a-z”,‘false’);

repeatability:
i have tried this with a-z, [a-z] [a-zA-Z0–9] [a-zA-Z0–9]+ [a-z]+ [a-z]{6,50} ← THESE
in every event the javascript dialog pops up and shows me one of these and wont let me register.
i also tried with single quotes, to no avail…

undesired fix:
without the Pattern rule line, registration and login work perfectly and entries are in user DB.
any assistance much appreciated to get this pattern validator rule to work. fyi.

testdata:
i was testing with username = jamesdan and password = kljhyt. very simple. should work…

James

David Grudl
Nette Core | 8218
+
+1
-

use addRule($form::PATTERN, 'error message', '[a-z]+');

jdan1131x
Member | 41
+
0
-

->addRule($form::PATTERN, ‘error message’, ‘[a-z]+’);

works perfectly, thanks!

per 3.1 API
static bool validatePattern(Control $control, string $pattern, bool $caseInsensitive = false)
fyi…

thanks again!
James

dakur
Member | 493
+
0
-

@jdan1131x Also, please use code formatting in your posts, the code is better readable then and it is clearer what is code and what are sentences. There is this “PHP code” icon above the textarea. 🙂 Thank you.

jdan1131x
Member | 41
+
0
-

will do :-) i missed it… magnifying glass getting repaired..hehe