I did something similar to the jquery above, but I needed to reset my form data and graphic attachment canvases.
So here is what I came up with:
That works well for me, for your application of just an html form, we can simplify this jquery code like this: