Clearing the values of form fields when a visitor browses back to a previously submitted form

Updated on 20-October-2016 at 10:16 AM

Business Catalyst End of life announcement - find out more details.

Implement the following script to make your site more secure. For example, add this code to ensure that a visitor's entries into a web form are not 'viewable' by navigating 'back' to the page after the form's submission. Place the following code on the page with the web form.

<script type="text/javascript">  
var ele = document.getElementsByTagName('input');  
var len = ele.length;  
for(var i=0;i<len;i++){  
    if(ele[i].type == 'text')  

Another option is to add the following to your web form: autocomplete = "off"

<form name="form1" id="form1" method="post" autocomplete="off"  action="">
Jquery Version You can add the following into your script or page to clear form fields:
$(this).closest('form').find("input[type=text], textarea").val("");