How to set the number of characters in a text field

How to set the number of characters in a text field

by Carlos Rozas -
Number of replies: 3
Hi,

I am newbie using Database module and would like to find a way to set the maximun number of characters allowed in a text field entry or textarea field entry,
this will very usefull to set limits for posting homework with a restriction in the size of it.

Thanks in advance for any clue how to doit.

Carlos Rozas
Neuroscience Lab
University of Santiago
Chile
Average of ratings: -
In reply to Carlos Rozas

Re: How to set the number of characters in a text field

by Dennis Daniels -
I found this link
http://codewalkers.com/archives/clientside/222.html
and this one too:
http://javascript.about.com/library/blcount.htm

I really like the idea of word count as well. Younger, less focused students, need specific targets and immediate feedback on their results... setting word count has always helped when giving written assignments and it would be a huge bonus in Moodle to have fields with word/letter count.

best
Dennis
In reply to Dennis Daniels

Re: How to set the number of characters in a text field

by Marc Couture -

Bumping this thread, as this functionality is still absent in the Database activity (at least in Moodle 2.8.5).  There HAS to be a way to insert some javascript in the activity's HTML template and, say, limit the number of characters that can be entered in various fields.

Any ideas are welcome!

In reply to Marc Couture

Re: How to set the number of characters in a text field

by William Lu -
Picture of Particularly helpful Moodlers

I tested the ‘Word count’ feature in Database ‘Add entry’ form with some JavaScript.

It only works when in < code > mode or when the HTML editor is disabled.

I’ve checked the links in Dennis’ post, the form has NO HTML editor as well.

I guess the Moodle HTML editor interferes the JavaScript I added.

That means, to be able to use the ‘Word count’ feature, we can only use ‘text input’ field, not the ‘text area’ field.

If you do want to use Textarea field, you have to tell your users to use Plain editor mode by click the <code> button, or to use the ‘disable Editor’ button. But that is not practicable.


Conclusion:

The 'Counter' only works in TextInput fields. See below:





Average of ratings: Useful (1)