Skip navigation
Currently Being Moderated

Adding extra message to the character count

Dec 10, 2012 3:43 AM

Hi

I would like to add an additional text, inline, to the character count on this "Text Area" input. Please advice.

 

RemainingText.png

 
Replies
  • Sudarshan Thiagarajan
    4,000 posts
    Oct 15, 2010
    Currently Being Moderated
    Dec 10, 2012 4:24 AM   in reply to Reynold Dreamweaver CS6

    Reynold, how are you? Been a while!

     

    Do you already have a functional form for this? If so, can you post the link so I can take a look and advice?

     

    What would you like to add? Can you also mention that here so one of us can give you the reuqired code?

     

    -ST

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 10, 2012 7:48 AM   in reply to Reynold Dreamweaver CS6

    Just guessing here, but what happens if you add desired text after the non breaking space entity on line 202

     

    <span id="countsprytextarea1"> add text here</span>

     
    |
    Mark as:
  • Sudarshan Thiagarajan
    4,000 posts
    Oct 15, 2010
    Currently Being Moderated
    Dec 10, 2012 8:16 AM   in reply to Ken Binney

    Ken, that will either break the widget constructor or will be ignored at runtime as the widget writes to the span tag based on the ID of the same.

     

    Reynold,

     

    find this line in SpryValidationTextArea.js (should be around Line 446):

    this.setCounterElementValue(this.options.maxChars - this.input.value.length);

     

    Change it to:

     

    this.setCounterElementValue(this.options.maxChars - this.input.value.length + ' characters remaining');

     

    -ST

     
    |
    Mark as:
  • Sudarshan Thiagarajan
    4,000 posts
    Oct 15, 2010
    Currently Being Moderated
    Dec 10, 2012 8:21 AM   in reply to Sudarshan Thiagarajan

    Also, if you want to be 'grammatically correct' in your prompt message, you could add 2 more lines:

     

    this.setCounterElementValue(this.options.maxChars - this.input.value.length + ' characters remaining');

                        if (this.options.maxChars - this.input.value.length <= 1){

                            this.setCounterElementValue(this.options.maxChars - this.input.value.length + ' character remaining');

                        }

     

    This way, if the maximum characters minus the actual input characters is less than or equal to 1, it will show character not characters remaining

     

    -ST

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 10, 2012 10:23 AM   in reply to Sudarshan Thiagarajan

    So glad you have our backs  :-)

    Thanks

     
    |
    Mark as:
  • Sudarshan Thiagarajan
    4,000 posts
    Oct 15, 2010
    Currently Being Moderated
    Dec 10, 2012 7:54 PM   in reply to Reynold Dreamweaver CS6

    Ken, I'm glad I can help

     

    Reynold, you're welcome. I'm doing just fine!

     

    -ST

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points