Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
ChronoForms 3.1 for Joomla! site Cookbook

You're reading from   ChronoForms 3.1 for Joomla! site Cookbook 80 recipes for building attractive and interactive Joomla! forms

Arrow left icon
Product type Paperback
Published in Aug 2010
Publisher Packt
ISBN-13 9781849510622
Length 376 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Bob Janes Bob Janes
Author Profile Icon Bob Janes
Bob Janes
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

ChronoForms 3.1 for Joomla! Site Cookbook
Credits
About the Author
About the Reviewer
1. Preface
1. Creating a Simple Form FREE CHAPTER 2. E-mailing Form Results 3. Styling your Form 4. Saving Form Data in the Database 5. Form Validation and Security 6. Showing your Form in your Site 7. Adding Features to your Form 8. Uploading Files from your Forms 9. Writing Form HTML 10. Creating Common Forms 11. Using Form Plug-ins 12. Adding Advanced Features

Adding a character counter to a textarea


Some users can get just a bit long-winded when presented with a text area to type into. When that happens it would be useful to be able to show the number of characters remaining and to block the input of extra characters if the limit is exceeded.

Getting ready

We'll use a very simple form created by the Form Wizard with just two elements — a TextArea and a Button. We will need to know the ID of the text area; by default it will be text_0, the same as the element name.

How to do it...

  1. 1. Create the form, save it, and view it in your browser.

  2. 2. Notice that although we've labeled the textarea 50 chars max it takes nearly 100 without complaint. In fact you could keep on typing for a long time and the textarea would just scroll down and accept the input.

  3. 3. We're going to add some JavaScript to the Form JavaScript box to count the characters:

    window.addEvent('load', function() {
    // execute the check after each keystroke
    $('text_0').addEvent('keyup', function...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image