ihtus
ihtus

Reputation: 2811

autocomplete='off' functionality for a div

I am using divs to hold all inputs. When I refresh F5 in Firefox values that were entered (but not saved) remains on the form.

How do I force all inputs to be empty when they are really empty after page refresh?

A solution would be autocomplete='off', but it's good only for a form.

Is there a similar functionality when a div is holding the input elements?

A HTML, JavaScript or jQuery solution would be ok.

EDIT: Also another solution could be applying autocomplete='off' to all inputs but I think this is not an elegant solution..

Upvotes: 0

Views: 2333

Answers (2)

RahulOnRails
RahulOnRails

Reputation: 6542

While loading of page, just put inside the document.ready statement of jquery

$('#<form_id>')[0].reset();

Example :

<script type="javascript">
  $(function() {
     $('#<form_id>')[0].reset();  

  });
</script>

Just try this at your html page.

<div class="test_value"> Test </div>
<div class="test_value"> asdfTest </div>
<div class="test_value"> Tes asd fast </div>
<div class="test_value"> Testa dfasdf </div>

$(function(){
       $('.test_value').text('');
}); 

JsFiddle

Upvotes: 0

Govind Singh
Govind Singh

Reputation: 15490

You can use autocomplete="off" property for each input.

Upvotes: 1

Related Questions