Welcome, Guest
Username: Password: Remember me

TOPIC: Textarea validation

Textarea validation 13 Jul 2012 08:55 #2787

  • VentoStudio
  • VentoStudio's Avatar
  • Offline
  • New Member
  • Posts: 11
  • Thank you received: 2
  • Karma: 0
Hi,
in my table is a text field checked by the regular expression: ^.{0,2500}$

when want to go to a new line (pressing enter key) shows the validation error.

I want to have text box where a user can enter up to 2500 characters long and can move to the new line.
How do I?
The administrator has disabled public write access.

Re: Textarea validation 24 Sep 2012 12:33 #3942

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi there,

text fields don't typically allow new line characters so, for a field in which you wish to store descriptive text, especially when it needs to store new lines, you should almost always use a richtext field instead.

If you need to restrict the char length, you can still do that using regex.

Check out some other Joomla DB tables, for example, '#__content' for example to see how it stores articles.

Hope this helps!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.
The following user(s) said Thank You: admin

Re: Textarea validation 14 Nov 2012 16:44 #5361

  • g1smd
  • g1smd's Avatar
  • Offline
  • Junior Member
  • RegEx fiend!
  • Posts: 31
  • Thank you received: 26
  • Karma: 6
^.{0,2500}$

Are you sure you want to allow ANY character, or should you be restricting the input to letters, digits and certain punctuation?

Are you sure that 0 is a valid value, so that the user can leave the field blank - or should there be a larger minimum size?
Online since 1996.
Last Edit: 14 Nov 2012 19:22 by g1smd.
The administrator has disabled public write access.

Re: Textarea validation 14 Nov 2012 17:42 #5362

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Agreed (@g1smd), you might at least want to specify a realistic minimum length rather than 0 however, textarea inputs can be configured to allow/disallow certain html tags using some of joomla's built in filters in addition to restricting lower and upper bounds for the length of input value. Here are some of the filters:

Default Black List - All the tags and attributes are allowed expect the following ones:
Tags - 'applet', 'body', 'bgsound', 'base', 'basefont', 'embed', 'frame', 'frameset', 'head', 'html', 'id', 'iframe', 'ilayer', 'layer', 'link', 'meta', 'name', 'object', 'script', 'style', 'title', 'xml';
Attributes - 'action', 'background', 'codebase', 'dynsrc', 'lowsrc';
More tags and attributes can be entered in the Filter Tags and Filter Attributes fields. The list items should be separated with comma.

Custom Black List - Can overwrite the tags and attributes included in the above list. Again, they should be added in the Filter Tags and Filter Attributes fields.

White List - Only the specified tags and attributes will be allowed.

No html - All the HTML code will be filtered.

No filtering - The filtering is disabled. Usually this option is selected for the Joomla 2.5 Super Users and Administrators accounts.

These can actually be set in the XML:
See howl: docs.joomla.org/Textarea_form_field_type

Gez

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.
The following user(s) said Thank You: admin, g1smd
Time to create page: 0.080 seconds

Get Started