我输入密码,然后重复密码字段,但红色警报没有消失,当我点击提交按钮它是成功的,没有错误验证.
当我重复密码时,如何使比较警报消失?
当我重复密码时,如何使比较警报消失?
这是我的规则代码在模型
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(); ?>
这是我的截图
在我的情况下,我刚刚更改了密码验证:
原文链接:https://www.f2er.com/php/138172.html['password',
到这个:
['password_repeat','compare','compareAttribute' => 'password'],