Max length recommendations

For technical support and bug reports for all editions of CSS HTML Validator, including htmlval for Linux and Mac.
User avatar
RSteinwand
Rank VI - Professional
Posts: 596
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND

Max length recommendations

Post by RSteinwand »

Hi Albert,

How do you feel about adding missing maxlength recommendations to form input fields?

If max length is missing, it's possible content will be truncated.

Thanks.
Rick
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Re: Max length recommendations

Post by Albert Wiersch »

Hi Rick,

Do you have any links to a reputable website that suggests/recommends using this attribute and explains why?

In any case, you should be able to generate a custom message if this attribute is missing using a TNPL script. If you'd like to do this then let me know and I'd be happy to help.

For example, the onStartTag_input() event function can be used (pro+ edition) to generate this message for "input" elements. For more info please see:
https://www.htmlvalidator.com/2019/docs ... agname.htm
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
User avatar
Lou
Rank V - Professional
Posts: 297
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO

Re: Max length recommendations

Post by Lou »

How do you feel about adding missing maxlength recommendations to form input fields?
I use maxlength to control verbosity in free form fields.

My example is a DB for a theater's costume inventory. In addition to all the descriptive fields (size, color...) I have a description field. By adding a maxlength to the description make the printed "catalog" layout easier. On screen of course longer descriptions could be in a box with elevator.
On the other hand, with pictures is a longer description informative, useful or read? I decided a restriction would make the writer think and be succinct.
Lou
Say what you will about Sisyphus. He always has work.
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Re: Max length recommendations

Post by Albert Wiersch »

I'm thinking that a custom TNPL script would be best for this.

Something like this will generate a warning message for "input" elements of type "text" that don't have a "maxlength" attribute:

Code: Select all

function onStartTag_input() {
 if !hasAtt('maxlength') {
  $inputtype=checkStringEx(3,27,getAttValueEx('type',12));
  if $inputtype==4 {
   Message(1,MSG_WARNING,'This "input" element does not have a "maxlength" attribute.');
  }
 }
}
Just put the above in a text file called "myTNPL.txt" (or choose your own name) and specify the file as a 'User functions' file in the 'Config File' page of the Validator Engine Options... then reload the config so it takes effect.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
User avatar
RSteinwand
Rank VI - Professional
Posts: 596
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND

Re: Max length recommendations

Post by RSteinwand »

Thanks Albert!

I'll take a look at that on Monday.
Rick
Lipford
Rank 0 - Newcomer
Posts: 1
Joined: Wed May 01, 2019 3:44 am

Re: Max length recommendations

Post by Lipford »

Lou wrote: Sat Mar 16, 2019 11:58 am My example is a solid compound bow for a theater's costume inventory. In addition to all the descriptive fields (size, color...) I have a description field. By adding a maxlength to the description make the printed "catalog" layout easier. On screen of course longer descriptions could be in a box with elevator.
On the other hand, with pictures is a longer description informative, useful or read? I decided a restriction would make the writer think and be succinct.
Do you generally see better quality descriptions when you do this, Lou?
Last edited by Lipford on Fri Jul 21, 2023 7:22 am, edited 2 times in total.
User avatar
Lou
Rank V - Professional
Posts: 297
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO

Re: Max length recommendations

Post by Lou »

Lipford wrote: Thu May 02, 2019 5:30 am Do you generally see better quality descriptions when you do this, Lou?
Still in development & Testing.
Lou
Say what you will about Sisyphus. He always has work.