萬盛學電腦網

 萬盛學電腦網 >> 腳本專題 >> javascript >> JS防止用戶多次提交

JS防止用戶多次提交

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>表單提交後按鈕禁用</title>
<script type="text/javascript">
function sub() {
	document.forms[0].elements[0].disabled = true;
	document.forms[0].submit();
}
</script>
</head>
<body>
	<form action="login.action" method="post">
		<input type="button" name="btn" value="提交表單" onclick="return sub();" />
	</form>
</body>
</html>

表單提交後,提交按鈕不可用

copyright © 萬盛學電腦網 all rights reserved