PHP   发布时间:2022-04-09  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了验证 – 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'],

大佬总结

以上是大佬教程为你收集整理的验证 – Yii2比较验证器警报不消失全部内容,希望文章能够帮你解决验证 – Yii2比较验证器警报不消失所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: