An Easy way to avoid loss of form contents even if we refresh the page. Developed in pure Javascript. So, not required any additional libraries like jQuery.
<script src="https://cdn.jsdelivr.net/gh/akjpro/form-anticlear/base.js"></script>
Add class form-anticlear
in form or any elements.(This will consider as the parent-element, and all its child elements will get this affected)
<form class="form-anticlear"><input type="text" name="myText">
</form>
Add class form-anticlear-none
to the elements. This will be affected to the applied elements and its child elements.
<input type="text" class="from-anticlear-none">
formAntiClear.clear()
: to clear all the form elements coming inside of form-anticlear
class.
formAntiClear.clear(<Selector>)
: To clear the elements with selectors (id, classname etc).
Able to handle anticleared
event to do something after data loaded to form.
document.addEventListener('anticleared', function (e) { //Statements }, false);
$(document).on('anticleared',function (e) { //Statements })