Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsRepositoryRepositoryLimiting length of description field in a template?Limiting length of description field in a template?
Previous
 
Next
New Post
6/15/2011 7:41 AM
 
How would I limit the length of the Description field in a template?
 
New Post
6/15/2011 9:55 AM
 
There's nothing in the template or settings that you can do to set a character limit on a multiline text box.  ASP.NET renders it as a text area which does not have a MaxLength property.  You could accomplish it however, with a little jQuery. Add some script to the footer.html template to capture the keypress on the Description field and suppress any keystrokes once the desired length has been reached.  

I would also suggest you have a little div area in your template.html file where your jQuery function can display a message as to why the keystrokes aren't working from the user's perspective.  You might even have a little character counter displayed as they type.. something like .... "140 character maximum, 37 characters left" ... which you can place under the Description field text area.

 
New Post
6/15/2011 11:24 AM
 
oops, sorry ... you would add the jQuery to the   form.html  template file, not the footer.html file.

 
New Post
8/3/2011 4:28 AM
 
Is there any chance you could post some example code to illustrate how to do this? My Jscript is poor and I don't know how to capture the keypress.

TIA
 
New Post
8/3/2011 5:27 AM
 
I added the following script at the bottom of the form.html file, but when I view the page I get the error "Multiple controls with the same ID '__TEDescription' were found. FindControl requires that controls have unique IDs."
What did I do wrong?

<script src="http://api.jquery.com/scripts/events.js"></script>
<script>
var xTriggered = 0;
$("#[DESCRIPTION]").keypress(function(event) {
  if ( event.which == 13 ) {
     event.preventDefault();
   }
   xTriggered++;
   var msg = "Handler for .keypress() called " + xTriggered + " time(s).";
  $.print( msg, "html" );
  $.print( event );
});
});</script>
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsRepositoryRepositoryLimiting length of description field in a template?Limiting length of description field in a template?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out