dsuoedtom207012191 2012-05-02 09:37
浏览 169

如何在文本框中删除自动完成功能

I need to remove autocomplete in all the textbox with in my page so I have given <input name="txt_username" id="txt_username" type="text" value="" autocomplete="off" /></dd></dl>

But it's not working does anyone know this?

  • 写回答

4条回答 默认 最新

  • douhuai2015 2012-05-02 09:41
    关注

    Autocomplete, unless you're doing something crazy with AJAX, is a client-side thing and you can't always control it like that.

    Since autocomplete works by caching your previous entries for a specific input text name, many banks randomly generate the input text name at each form page load but keep track of what is generated either somewhere else in a hidden input element or on the server side.

    So instead of

    <input name="txt_username" id="txt_username" type="text" value="" autocomplete="off" />
    

    It might be something like

    <input type="text" name="f6Lx571p" id="txt_username"/>
    <input type="hidden" name="username_key" value="f6Lx571p" />
    

    And the server-side code adjusted accordingly. For example, PHP code might have looked like:

    <?php
    $user = $_POST['txt_username'];
    ...
    

    but it would have to be changed to something like:

    <?php
    $user = $_POST[$_POST['username_key']];
    ...
    

    Its a bit annoying, but it works.

    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c