This can be tricky since you are trying to delete an in use object.
Take a minute to think what could happen if what is modifying the form and has more work to do suddenly disappears.. It might be like writing a note on a piece of paper and have paper disappear before you sign the note.
You can use JavaScirpt to hide and make the field read only. Out of sight and non-click able.
Have you looked at what the signing does to the various form fields?
The problem with this is removing the button after the signature is applied will show that the document has changed after the signature was applied when the signature is verified. But that may be OK.
Another problem is of you remove or hide the button after it's clicked and an error occurs, it will remain gone or hidden so the user will be unable to click it again if the condition that caused the error is corrected.
Regarding signatures locking the document, this is an option that the user can select if the signature field that's being signed is the last blank signature in the document.
GKaiseril: I had the same concerns you did about removing the submit button while it was submitting, but when I submitted it before signing anything and the button was removed, it did submit fine.
George: The security may already be compromised by a different script that is working; this isn't a huge deal, but it would be nice if it would verify. The two signatures are for a borrower and optional co-borrower. We've currently got it set up so that once the primary signature is signed, a script checks whether a co-borrower exists, and if not, removes the second signature field (which works fine at the moment). It's set up to run on mouse down, so I'm not sure if it would run before or after the signature actually completes. Actually, this brings me back to a question I had when I first started working on this that I've just been working around: is it possible to create a script that runs when the document first opens? I searched for this for a while and never found any reference to it. If so, I could avoid the need to have a script on the signature field. As far as setting a variable to keep track of it, it seems to me like once we set the variable, the submission could still fail, but the variable would still be set and prevent submitting again. However, I might be able to check the documentFileName. When we archive the submitted PDF, we assign it an automatically generated name like 00000000467.pdf, so I can have the submit button check whether the name matches the original name (which we already store in a hidden field). In fact, if it's possible for the script to run when the document first opens, the submit button can be disabled (or hidden/readonly, if that would work better with document security) from the very beginning instead of disappearing when they try to click on it.
Regarding the variable, if you use a try/catch block and only set the variable if no error is caught, it should help.