In QuickForm it could be done kind of like this:
$form = new HTML_QuickForm2('changepassword');
$passwordold = $fs->addElement('password', 'oldpassword')->setLabel('Old password');
function chkPass($fields)
{
if ((strlen($fields['oldpassword']) && (md5($fields['oldpassword'])<>passwordcheck())))
{
return array('oldpassword' => 'Old password does not match your records.');
}
return true;
}
$form->addFormRule('chkPass');
But QuickForm2 does not seem to have addFormRule(), is there anything replacing it?
Found the answer:
function chkPass($password)
{
return ($password == 'qwerty');
}
$oldpassword->createRule('callback', 'Old password does not match your records.', 'chkPass')