我输入密码,然后在重复密码字段中重复,但红色警报没有消失,当我单击提交按钮时,它是成功的并且没有错误验证。重复密码时如何使比较警报消失?
这是我在模型中的规则代码
public function rules()
{
return [
['username', 'filter', 'filter' => 'trim'],
['username', 'required'],
['username', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This username has already been taken.'],
['username', 'string', 'min' => 2, 'max' => 255],
['email', 'filter', 'filter' => 'trim'],
['email', 'required'],
['email', 'email'],
['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.'],
['password', 'required'],
['password','compare'],
['password', 'string', '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(); ?>
这是我的截图