Form Processing: Order of events?
I cannot find a reference to the complete order of form events when someone clicks the 'submit' button. I am trying to screen submitted comments to eliminate spam, bots, and inappropriate language. I am trying to accomplish this as follows:
(1) onclick event handler of the submit button runs server-side validation of a CAPTCHA on the page - this has been tested and works.
(2) if the submit button's handler returns 'true', an onsubmit event handler for the form runs a validation script for the form field's contents (to assure that the user has submitted a valid email address, there are no URLs in the comments text, and that no inappropriate language has been used.)
(3) then, and only if the validation script returns 'true', the form's action calls a server-side script that appends the user's submission to a file on the server for subsequent posting to a comments page.
So, I assume that the order of events is as follows:
Submit-button onclick -> validateCaptcha: false: exit; true: Form onsubmit -> validate form contents: false: exit; true: Form action -> server-side processing to add form data to a file.
What I specifically want to know is the following:
(1) if the submit button has a handler, will the form's onsubmit handler also be processed, or does one event handler override the other?
(2) if both will be executed, will the events be processed in the order that I have assumed?
Finally, if my assumptions are false, please describe what actually needs to happen to accomplish what I have set out.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)