Get it All
Together

Because someone asked me and because I haven’t seen quite the same solution out there on the nets, I’m posting this really quick for the benefit of those who need a quick submit button confirmation. If, for example, you want to prompt users to confirm whether or not they wish to delete an item out of a form, you can use the below JavaScript function to get it done. The function is designed to serve as confirmation for many different types of events, so it’s quite flexible:

// confirmButton: simple function to test user response
function confirmButton(message) {
	var conf = confirm(message);
	if(conf) {
		return true;
	} else {
		return false;
	}
}

To us it, I use my trusty Unobtrusive JS action loading function like so:

addEvent(editsubmitbtnz[i], 'click', function() { return confirmButton('Are you sure you want to edit this feed?'); });

You could also add the function directly to the button like so:

<input type="submit" value="Delete This" onclick="return confirmbutton('Are you sure you want to delete this feed?');" />

The result is a JavaScript function that will halt all action on the screen when you hit the submit button that the function is assigned to. It prompts the user to say whether or not they agree with the statement passed as a reference to the function, then pass that value (true or false) back to the page and either submit the form as normal or cancel the operation.