【问题标题】:Autocomplete offf in email and password field in yii2 using ActiveForm使用 ActiveForm 在 yii2 中的电子邮件和密码字段中自动完成关闭
【发布时间】:2019-07-05 16:16:11
【问题描述】:

我在 yii2 中使用 Activeform 作为表单,我使用电子邮件和密码输入电子邮件和密码。但是我已经登录了电子邮件和密码,记住我而不是我的表单上的电子邮件和密码字段自动完成。 该代码如下:

所以请帮助使用 yii2 删除自动完成功能。 这是图片中发生的事情:

我已使用以下链接获取解决方案,但不适用于我: Yii: disable autofill of username and password fields on chrome

<div class="col-md-12 mb-0">
<?=$form->field($model, 'coupon_code', ['inputOptions' => ['autocomplete' => 'off'],'template' => ''
. '<div class="input-group mb-3 coupon_parent_div">'
. '{input}'
. '<div class="input-group-append">'
. '<button type="button" id="coupon_btn" class="btn btn-md btn-secondary" onclick="cart_refresh();">Apply</button>'
. '</div>'
. '</div>'
. '{error}'])
->textInput(['class' => 'form-control my_input_border', 'maxlength' => true, 'placeholder' => $model->getAttributeLabel('coupon_code')])?>
</div>
<div class="form-row">
<div class="col-md-3 mb-0">
<?= $form->field($model, 'cc_cvv')->passwordInput(['class' => 'form-control my_input_border', 'maxlength' => 5, 'placeholder' => 'CVV', 'autocomplete' => 'off'])->label(false) ?>
</div>
</div>
<div class="card credit_card_custom_css">
<div class="card-body">
<div class="form-row">
<div class="col-md-7 mb-0">
<?= $form->field($model, 'cc_name',['inputOptions' => ['autocomplete' => 'off']])->textInput(['class' => 'form-control my_input_border marginBottom15', 'maxlength' => true, 'placeholder' => $model->getAttributeLabel('cc_name')])->label(false) ?>
</div>
<div class="col-md-5 mb-0">
<?= $form->field($model, 'cc_number',['inputOptions' => ['autocomplete' => 'new-password']])->textInput(['class' => 'form-control my_input_border marginBottom15', 'maxlength' => true, 'placeholder' => $model->getAttributeLabel('cc_number')])->label(false) ?>
</div>

</div>
<div class="form-row">
<div class="col-md-3 mb-0">
<?= $form->field($model, 'cc_cvv',['inputOptions' => ['autocomplete' => 'new-password']])->passwordInput(['class' => 'form-control my_input_border marginBottom15', 'maxlength' => 5, 'placeholder' => $model->getAttributeLabel('cc_cvv')])->label(false) ?>
</div>
</div>
</div>
</div>

这是发生在我身上的图片:

请帮我解决这个问题。

【问题讨论】:

    标签: javascript jquery css mysql yii2


    【解决方案1】:

    现代浏览器将忽略登录字段上的Autocomplete="off"

    如果网站为用户名和密码设置了 autocomplete="off" 字段,则浏览器仍会提供记住此登录信息,并且 如果用户同意,浏览器将在下一个自动填充这些字段 用户访问页面的时间。

    The autocomplete attribute and login fields

    【讨论】:

    • 感谢回答
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-12
    • 2016-01-03
    • 2020-09-21
    • 2015-10-20
    • 2014-06-09
    • 1970-01-01
    相关资源
    最近更新 更多