Note that there are some explanatory texts on larger screens.

plurals
  1. POjs word counter - when refreshing the page the counter goes back to original count
    primarykey
    data
    text
    <p>Whenever someone refreshes my page or submits the form on the page (and there is an error), the word counter goes back to the original amount of characters. I have a word counter in my form for a particular field.</p> <p>As such, whenever someone tries to fill out our form, our validation tells them that they have to fill out the specific question and does not allow them to submit the form. I realize I could quick-fix the validation by taking out where it says that the textarea cannot be left empty. But that is not a solution I can envisage.</p> <p>Here is the code I have:</p> <pre><code> &lt;script language="javascript" type="text/javascript"&gt; function textCounter(field,cntfld,maxlimit) { var cntfield = document.getElementById(cntfld); if (field.value.length &gt; maxlimit) field.value = field.value.substring(0, maxlimit); else cntfield.innerHTML = maxlimit - field.value.length; } &lt;/script&gt; </code></pre> <p>Followed by my html</p> <pre><code> &lt;div&gt; &lt;textarea class="cf_inputbox required" rows="7" id="text_id" title="title_test" cols="50" name="text_id" onKeyDown="textCounter(this,'counter_length',200)" onKeyUp="textCounter(this,'counter_length',200)"&gt;&lt;/textarea&gt; &lt;br/&gt; &lt;span id="counter_length"&gt;200&lt;/span&gt; Left &lt;/div&gt; </code></pre> <p>How could I modify my code so that if the page is refreshed OR if the form is submitted (with errors - and thus the validation kicks in), that the word counter would stay at the CURRENT number and not go back to 200?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload