4
It is entirely how the functionality is implemented in the module.
Many modules (eg also Formulaire) do the following after the user has submitted the form:
- check permissions
- check captcha
- check data
- save data
If the check captcha fails, the entered data is discarded and the user is redirected to the general starting point of the module. All entered data is discarded, which is a severe punishment for the user, if the filled in form is large.
Other modules as eg Contact Us use a form object (= some data container), which contains all data of the form and then do the following:
- create an empty form object.
- show the form with the form object data.
- user fills in and do a submit.
- check permissions
- copy data entered to form object.
- check captcha
- check data
- save data
In this case there is always a form object updated with the user last edits, that is used to iniate the values for the form. If the captcha check fails the form is regenerated with the updated form object, and all answers are present again.
The data check are checks by PHP, to see if some enterences are coherent with each other and are not the Javascript checks, that are done at the user side in his browser to check if the obliged fields are not empty and generate a popup alert, that some fields input are missing. The latter have no influence on the partial filled in form, because it is not yet submitted.
An other way could be that the captcha code was sent as an hidden field as MD5 encoded. In that way the Captcha verification could also be done on the User side with Javascript with a verification function that alerts the user for a wrong captcha without submitting the form and thus also not loosing his work on the form.
This might be the simpliest and in general the most applicable method, because implementing a form object requires some turn upside down programming in the module and is rather tedious.