Page 1 of 1
Max length recommendations
Posted: Fri Mar 15, 2019 4:18 pm
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.
Re: Max length recommendations
Posted: Fri Mar 15, 2019 8:38 pm
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
Re: Max length recommendations
Posted: Sat Mar 16, 2019 11:58 am
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.
Re: Max length recommendations
Posted: Sat Mar 16, 2019 12:27 pm
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.
Re: Max length recommendations
Posted: Sun Mar 17, 2019 8:34 pm
by RSteinwand
Thanks Albert!
I'll take a look at that on Monday.
Re: Max length recommendations
Posted: Thu May 02, 2019 5:30 am
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?
Re: Max length recommendations
Posted: Thu May 02, 2019 10:14 am
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.