Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » Restrict the input size of a multi-line text box
Restrict the input size of a multi-line text box [message #2087] Thu, 28 May 2009 15:38 Go to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
I have a database attribute of type TEXT. I want to restrict the actual amount of text that is entered into this field but am not sure how to do it.

My control is a multi-line text box. I wondered if I could restrict the number of rows in this box and prevent it from auto scrolling once it is full?

In the DICT application I also tried restricting the column size (on the update column screen), but it still seems to allow me to enter and save too much data.

Any suggestions?
Re: Restrict the input size of a multi-line text box [message #2088 is a reply to message #2087] Thu, 28 May 2009 18:19 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
A multi-lne text box uses the HTML textarea element, and the HTML specification does not allow for any restrictions in the amount of data which may be input by the user. Because of this there is nothing the framework can insert into the HTML document to restrict user input. There is no way to turn off the scroll bar, so you cannot use the numbers of lines and rows to restrict user input.

You can restrict the column size in the data dictionary, but this cannot be checked in the server-side code until after the form has been posted.


Re: Restrict the input size of a multi-line text box [message #2089 is a reply to message #2087] Thu, 28 May 2009 19:04 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
What does the column size attribute in the dictionary actually do? I was able to set a small value but save larger amounts in the db. Do I have to perform some manual validation and, if so, how do I do that? I suppose it makes most sense to trap this and display a custom error.
Re: Restrict the input size of a multi-line text box [message #2090 is a reply to message #2089] Fri, 29 May 2009 05:08 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
The column size attribute is supposed to be checked during the standard field validation, and if the input exceeds this value a standard error message is supposed to be generated. I say "supposed", but due to a bug Embarassed when checking the character encoding this code was skipped. This is fixed in the attached file.

This means that the length of the string can be validated against the column size specified in the data dictionary with standard framework code, so no custom code should be necessary.


Re: Restrict the input size of a multi-line text box [message #2091 is a reply to message #2087] Fri, 29 May 2009 09:47 Go to previous messageGo to next message
gpatti is currently offline  gpatti
Messages: 283
Registered: August 2008
Senior Member
Thanks, that works and makes sense to me now!

Having played around with this a bit more I've decided that what I really need is to restrict the number of lines of text, rather than the number of characters. I'll need to write some custom code to count carriage returns and wrapped lines. Does anyone have anything like this already that I can use?
Re: Restrict the input size of a multi-line text box [message #2093 is a reply to message #2091] Fri, 29 May 2009 10:08 Go to previous message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
You might be able to do what you want with javascript, but as I don't use javascript I cannot provide a workable solution.

Previous Topic: Default the select checkbox to 'selected'
Next Topic: Display a message in an ADD2 transaction
Goto Forum:
  


Current Time: Thu Nov 28 00:13:22 EST 2024

Total time taken to generate the page: 0.01209 seconds