JS防止フォームの重複提出

1104 ワード

/*  1:      JS  */
		var submited = false;
		function checkSubmit() {
			if (!submited)
			{
				submited = true;
				return true;
			}
			else {
				alert("       !");
				return false;
			}
		}

		function submitForm() {
			var f = document.getElementById("inputForm");
			if (checkSubmit())
			{
				f.submit();
			}
		}
 
<form id="inputForm" action="http://www.csdn.net" method="post">
		name:<input type="text" name="name"><br>
		pass:<input type="password" name="password"><br>
		<input type="button" value="submit" onclick="submitForm();"/>
	</form>
 
/*  2:              ,        */
		function submitForm() {
			var f = document.getElementById("inputForm");
			f.disabled = true;
			f.submit();
		}