---
title: "html禁止清除input文本输入缓存"
author: "xp9802"
date: "2014-11-14T10:06:47Z"
tags: []
categories: ["Web前端"]
slug: "html-input"
draft: false
lastmod: "2014-11-14T10:06:47Z"
id: 2155875
url: "https://xp9802.iteye.com/blog/2155875"
---

多数浏览器默认会缓存input的值，只有使用ctl+F5强制刷新的才可以清除缓存记录。  
如果不想让浏览器缓存input的值，有2种方法：

方法一：   
在不想使用缓存的input中添加 autocomplete="off";   
eg: &lt;input type="text" autocomplete="off" name="test" /&gt;

方法二：   
在 input 所在的form标签中添加 autocomplete="off";   
eg:  
&lt;form action="#" autocomplete="off"&gt;  
&lt;input type="text" autocomplete="off" name="test" /&gt;  
&lt;/form&gt;