Persistence of Form Field Values
You may notice that the user entered form field values being cleared upon redirect back to the original web form. This redirect usually happens when user enters incorrect CAPTCHA code, there is an error during processing, or any kind of error that prevents form data being forwarded further.
For those, who don't have their own implementation of persistence, we've put together a simple script that will remember the form values and will automatically populate the form fields upon redirect. This will get rid of necessity for users to re-enter the field values upon each redirect. To enable this persistence feature,
Step 1
Please insert the following line of HTML code anywhere inside <head>...</head> block in your web form page:
<script language="javascript" type="text/javascript" src="http://www.captchapro.com/global/js/formfields_persistence.js"></script>
Step 2
Then call the persist() function right after the form fields have been successfully validated, but before the form is submitted. You would need to pass the persist function the form object that you wish to remember the values for.
See a sample implementation example below. This example is provided for general guidance to help you better understand the persistence mechanism. The exact placement of the persist() function call will vary depending on your validation script.
<html>
<head>
<title>Sample Title</title>
<script language="javascript" type="text/javascript" src="http://www.captchapro.com/global/js/formfields_persistence.js"></script>
... ... ...
<script type="text/javascript">
function validateAndSubmitForm(theForm) {
... ... ...
persist(theForm);
theForm.submit();
}
</script>
... ... ...
</head>
<body>
... ... ...
<form name="integration_example_form" method="POST"
action="http://app.captchapro.com/captchapro_war/validation">
... ... ...
<input value="Submit" type="button" onClick="javascript:validateAndSubmitForm(document.integration_example_form);">
</form>
</body>
</html>
|
During execution of persist function the field values will be saved inside a cookie file, so for this to work the user browser must accept cookies. Also, due to the limitation of cookies this approach may not work for long forms which capture a lot of data. Please give it a try and let us know if you have any suggestions or ways to improve this approach.
» Back to examples
|