You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Codeigniter:Chrome自动填充导致提交后输入框值变更问题

Fixing Chrome Auto-Fill Issue on CodeIgniter Password Change Form

Ah, I feel your pain—browser auto-fill can be incredibly stubborn, especially when it messes with password fields that shouldn’t get pre-filled. Let’s walk through a couple of reliable solutions tailored to your CodeIgniter form:

1. Use the Standard autocomplete="new-password" Attribute

Modern browsers (including Chrome) recognize the new-password value for the autocomplete attribute as a signal that this field is for setting a new password, not logging in. This tells Chrome to skip filling it with saved credentials.

Modify your password input field like this:

<input type="password" id="inputPasswd" name="password" placeholder="New password" value="" autocomplete="new-password">

This is the most clean and standards-compliant approach, so it should be your first try.

2. Add a "Decoy" Hidden Password Field

If Chrome still ignores the new-password attribute (it can happen in some edge cases), you can trick it by adding a hidden password field before your real one. Chrome will fill this decoy field instead of your actual password input.

Update your form like so:

<form action="<?php echo site_url("Manage/changeUserPassword"); ?>" method="post">
  <input hidden class="inputwithiduser" type="text" name="iduser" value="">
  <!-- Decoy field to catch auto-fill -->
  <input type="password" style="position: absolute; left: -9999px; top: -9999px;" name="fake_password" autocomplete="off">
  <input type="password" id="inputPasswd" name="password" placeholder="New password" value="" autocomplete="new-password">
  <button type="submit">Save...</button>
</form>

We use absolute positioning to move the decoy off-screen instead of display: none because some browsers ignore hidden fields when handling auto-fill.

Why autocomplete="off" Often Fails

You might have tried setting autocomplete="off" before, but Chrome intentionally ignores this for password fields in most cases (to prioritize user convenience). That’s why using new-password or the decoy method is more effective.

Give these solutions a shot—one of them should stop Chrome from messing with your password input after submission.

内容的提问来源于stack exchange,提问作者Luca4k4

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:03:07