Limit number of characters in textfields

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
JEngels
Posts: 17
Joined: 2014-03-10 14:16
Location: Germany

Limit number of characters in textfields

Post by JEngels » 2014-03-10 14:30

Hi,
I want to limit the number of characters the user can enter in the textarea.
An alternative solution would be a character-counter below the textfield.
Any ideas to realize that?

Thanks.
Koepi

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Limit number of characters in textfields

Post by a.gneady » 2014-03-24 14:31

You can use javascript to achieve this ... create a file in the "hooks" folder, naming it "tablename-dv.js" (where tablename is the name of the concerned table) and add code similar to this in it:

Code: Select all

jQuery(function(){
   jQuery('#fieldname').attr('maxlength', 40);
});
(where fieldname is the name of the concerned field). Change 40 to the desired limit.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

JEngels
Posts: 17
Joined: 2014-03-10 14:16
Location: Germany

Re: Limit number of characters in textfields

Post by JEngels » 2014-03-28 12:37

Thanks Ahmad, that works fine!
But realize that "maxlenght" doesn't work in IE9/8.
Spent a lot of time to find that out.
Installed IE11 - thats okay (FF also).

My next try: install a character counter below the textfield I want to be limited/counted.
Is this also possible by using the hook folder, or only by adding code directly in the table.php?

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Limit number of characters in textfields

Post by a.gneady » 2014-03-28 20:30

No it can be added using the same hook file using javascript ... you can find through Google lots of examples on how to implement this ... for example: http://stackoverflow.com/questions/5371 ... n-textarea
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

Post Reply