{ Disable That Form Submit Button }

I have a form for importing records from a CSV file into the database. Obviously, given enough rows, this could take a couple of seconds to run. When a user clicks “Import” you don’t really want them looking at an “Import” button that they can keep clicking, wondering what’s going on. So, disable it. Here’s how.

function doImport() {
	var button = document.getElementById("import-button");
	button.disabled = true;
	button.value = "Importing...";
	return true;
}
input type="submit" value="Import" id="import-button" onclick="doImport()" /

Leave a Reply

Your email address will not be published. Required fields are marked *