验证 – Yii2比较验证器警报不消失

前端之家收集整理的这篇文章主要介绍了验证 – Yii2比较验证器警报不消失前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我输入密码,然后重复密码字段,但红色警报没有消失,当我点击提交按钮它是成功的,没有错误验证.
当我重复密码时,如何使比较警报消失?

这是我的规则代码在模型

public function rules()
{
    return [
        ['username','filter','filter' => 'trim'],['username','required'],'unique','targetClass' => '\common\models\User','message' => 'This username has already been taken.'],'string','min' => 2,'max' => 255],['email','email'],'message' => 'This email address has already been taken.'],['password','compare'],'min' => 6],['password_repeat','safe']

    ];
}

和我的表格

<?PHP $form = ActiveForm::begin(); ?>

<h3>Your Account</h3>
<?= $form->field($modelUser,'username')->textInput(['maxlength' => 45,'class' => 'input-xlarge form-control']) ?>

<?= $form->field($modelUser,'password')->passwordInput(['class' => 'form-control input-xlarge']) ?>

<?= $form->field($modelUser,'password_repeat')->passwordInput(['class' => 'form-control input-xlarge']) ?>
<button class="btn btn-primary" type="submit">Continue</button>

<?PHP ActiveForm::end(); ?>

这是我的截图

在我的情况下,我刚刚更改了密码验证:
['password',

到这个:

['password_repeat','compare','compareAttribute' => 'password'],
原文链接:https://www.f2er.com/php/138172.html

猜你在找的PHP相关文章