Max length recommendations

For technical support for all editions of CSS HTML Validator. Includes bug reports.
Post Reply
User avatar
RSteinwand
Rank VI - Professional
Rank VI - Professional
Posts: 600
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND
Contact:

Max length recommendations

Post by RSteinwand » Fri Mar 15, 2019 4:18 pm

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
Site Admin
Posts: 3417
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Max length recommendations

Post by Albert Wiersch » Fri Mar 15, 2019 8:38 pm

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
Image
Albert Wiersch

User avatar
Lou
Rank V - Professional
Rank V - Professional
Posts: 277
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

Re: Max length recommendations

Post by Lou » Sat Mar 16, 2019 11:58 am

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
Site Admin
Posts: 3417
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Max length recommendations

Post by Albert Wiersch » Sat Mar 16, 2019 12:27 pm

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.
Image
Albert Wiersch

User avatar
RSteinwand
Rank VI - Professional
Rank VI - Professional
Posts: 600
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND
Contact:

Re: Max length recommendations

Post by RSteinwand » Sun Mar 17, 2019 8:34 pm

Thanks Albert!

I'll take a look at that on Monday.
Rick

Lipford
Rank 0 - Newcomer
Rank 0 - Newcomer
Posts: 1
Joined: Wed May 01, 2019 3:44 am

Re: Max length recommendations

Post by Lipford » Thu May 02, 2019 5:30 am

Lou wrote:
Sat Mar 16, 2019 11:58 am
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.
Do you generally see better quality descriptions when you do this, Lou?

User avatar
Lou
Rank V - Professional
Rank V - Professional
Posts: 277
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

Re: Max length recommendations

Post by Lou » Thu May 02, 2019 10:14 am

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.

Post Reply