Hello!
I created a form which redirects to protected page upon entering any five digits in password field.
Here's the code at Custom Server Side Validation:
Could you please give any hints to implementing regex check?
I created a form which redirects to protected page upon entering any five digits in password field.
Here's the code at Custom Server Side Validation:
<?php
$data =& $form->data['password'];
$regex = '[0-9]{3}';
if ( isset($data) && $data ) {
if ( preg_match($regex, $data) === 0 ) {
$form->validation_errors['password'] = "Invalid data";
return false;
}
}
?>Could you please give any hints to implementing regex check?
Hi kus_kus,
Basically that looks OK, I'd make some small changes to avoid a problem if $form->data['password'] isn't set and to add // to the regex:
Bob
Basically that looks OK, I'd make some small changes to avoid a problem if $form->data['password'] isn't set and to add // to the regex:
<?php
if ( isset($form->data['password']) && $form->data['password'] ) {
if ( preg_match('/[0-9]{3}/', $form->data['password']) === 0 ) {
$form->validation_errors['password'] = "Invalid data";
return false;
}
}
?>After that I'd add debug code to track exactly what is happening.Bob
This topic is locked and no more replies can be posted.
