---
title: "js 5秒之内禁止重复提交代码"
author: "windpoplar"
date: "2017-02-19T20:31:18Z"
tags: []
categories: ["互联网"]
slug: "js-5"
draft: false
lastmod: "2017-02-19T20:31:18Z"
id: 2357915
url: "https://windpoplar.iteye.com/blog/2357915"
---

01. &lt;script language="javascript"&gt;
02. var checkSubmitFlg = false;
03. function checkSubmit() {
04. if (checkSubmitFlg == true) {
05. alert("正在查询中..");
06. return false;
07. }
08. checkSubmitFlg = true;
09. setTimeout(function() {
10. checkSubmitFlg = false;
11. }, 5000);
12. return true;
13. }
14. &lt;/script&gt;
15. &lt;form method=post action="/search.jsp#m" target="\_blank"
16. onsubmit="return checkSubmit();"&gt;
17. &lt;input value="小说城" type="text" name="name" size="35" maxlength="10"&gt;
18. &lt;input type="submit" id="submitInput"/&gt;
19. &lt;/form&gt;