3

在 QuickForm 中,它可以像这样完成:

$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');

但是QuickForm2好像没有addFormRule(),有什么可以替代的吗?

4

1 回答 1

3

找到了答案:

function chkPass($password)
{
    return ($password == 'qwerty');
}
$oldpassword->createRule('callback', 'Old password does not match your records.', 'chkPass')
于 2012-08-14T05:38:58.597 回答