T his can be done using the onSubmit event. If the content is not accepted by your function the submit should be cancelled. This way nothing would be submitted unless your function accepted the content. If it returns true the submit will take place. If it returns false the submit will be cancelled.
C lick here to learn more about forms.
Click here to learn more about form validation. The trick to making the event work on an image is simply to turn the image into a link. If you really wanted the image to link to a page you should enter the address of the page here instead. C lick here to learn more about links and anchors. Click here to learn more about alert boxes.