Explorar el Código

Disable Submit button on submit

Alan Lam hace 6 años
padre
commit
3d5857f11e
Se han modificado 2 ficheros con 10 adiciones y 3 borrados
  1. 5 1
      public/js/app-project-form.js
  2. 5 2
      views/project_form.php

+ 5 - 1
public/js/app-project-form.js

@@ -40,6 +40,10 @@ $(function() {
 		return true;
 	});
 
+	$("#project-form").on("submit", function() {
+		$(this).find("button[type=submit]").attr("disabled", "disabled");
+	});
+
 	initialiseTooltips();
 
 });
@@ -129,4 +133,4 @@ function refreshLocationAlerts() {
 	else {
 		$("#selected-locations-alert").show();
 	}
-}
+}

+ 5 - 2
views/project_form.php

@@ -25,7 +25,7 @@ $time_of_day_options = [
 		Project
 	</h2>
 
-	<form method="post">
+	<form method="post" id="project-form">
 
 		<h3>Project Details</h3>
 
@@ -418,6 +418,9 @@ $time_of_day_options = [
 
 		<hr />
 
-		<button class="btn btn-primary" type="submit" name="submit" value="<?=$_SESSION["csrf_token"]?>">Submit</button>
+		<button class="btn btn-primary" type="submit">Submit</button>
+
+		<input type="hidden" name="submit" value="<?=$_SESSION["csrf_token"]?>" />
+
 	</form>
 </div>