根据表单结果有选择地将表单发布到不同的页面?

Say I have a simple form on a page called photo/delete.php. This form deletes an image specified by the user. All it is, is this:

<form action="?" method="post">
 <input type="checkbox" name="confirmDelete" value="confirm" />    
 <input type="submit" value="delete" />
</form>

So, this form contains a confirmation check box that must be ticked to ensure the image is deleted. How can I dynamically choose what page to POST this form to, based on its contents?

For example, if the checkbox is not checked, yet the submit button is clicked, I'd like to stay on the same photo/delete.php page and display an error, since its possible they really do want to delete the image and simply forgot to tick the box.

But otherwise, if everything is successful and the checkbox is ticked, I'd like to POST it to another page, say home.php since it makes no sense to stay on the same page of a just-deleted image.

How can I implement this?

You may try something like this

HTML:

<form action="delete.php" method="post">
    <input type="checkbox" name="confirmDelete" value="confirm" />    
    <input id="btn_delete" type="submit" value="delete" />
</form>

JS:

window.onload = function(){
    document.getElementById('btn_delete').onclick = function(e){
        var checkBox = document.getElementsByName('confirmDelete')[0];
        if(!checkBox.checked) {
            if(e && e.preventDefault) {
                e.preventDefault();
            }
            else if(window.event && window.event.returnValue) {
                window.eventReturnValue = false;
            }
            alert('Please check the checkbox!');
        }
    };
};

DEMO.