We have a need to validate a new comment before it is saved to the database. We want to gain access to the final form of the comment content, validate and if error, leave the user in the editor with an error message and thus the means to take corrective action.
The key is to have the validation done at the server (not on the client with Javascript). Ideally this validation would be activated by an event in view_jrComment_comment_save() that would allow us to perform the validation and then fail the transaction with an error message when appropriate.
Stated differently, the jrPostComment() Javascript function executes when a new comment is ready to be posted. This function issues an AJAX transaction which triggers view_jrComment_comment_save(). We would like to insert validation that looks and behaves like an error message issued by the view_jrComment_comment_save() function.
Aside:
The update portion of this problem is solved by a 'form_validate_init' listener. The create portion of the problem remains unsolved. We have a Javascript solution for the create portion but that is not ideal for security reasons and it is redundant code.
--
TiG
updated by @tig: 03/05/22 05:55:38AM