Form input maxlength error

For technical support for all editions of CSS HTML Validator. Includes bug reports.
Post Reply
User avatar
Lou
Rank V - Professional
Rank V - Professional
Posts: 269
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

Form input maxlength error

Post by Lou » Thu Sep 06, 2018 12:35 pm

Code: Select all

<fieldset style='border: 1px solid black; width: 975px; height: 250px;'>
	<legend>Description</legend>
	<p>
		<label for='tag'>Tag ID:</label>
		<input type='text' id='tag' name='tag' size='4' maxlength='4'  value= '<?php if ($old){echo "123";} ?>'>
	</p>
</fieldset>
When I validate this fragment, I get error:
The "maxlength" attribute specifies a maximum length of 4, which is less than the length of the value of the "value" attribute (which is 5). The length of the value of the "value" attribute must be equal to or less than the length specified by the "maxlength" attribute.
---
1 message for line 5
If I change maxlength='5' then of course the fragment validates.

This fragment is part of a PHP script data entry screen. If after a user enters data an error is detected the user is returned to the same screen, displaying the original data ~~ if($old) { echo "";} ~~. Conditional style = ' ' (not shown) are also used to highlight the fields with errors. There is also a popup box with error messages.

The tag data is a 1-4 digit number matching an inventory tag number. I don't want the user to be able to enter 5 digits.

Where does the 'length of the value of the "value" attribute (which is 5).' come from? If the value= does not include a script, things work as expected.

PRO version 2018(v18.0300)
Lou
Say what you will about Sisyphus. He always has work.

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3363
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Form input maxlength error

Post by Albert Wiersch » Thu Sep 06, 2018 2:05 pm

Hi Lou,

Sorry about that. CSS HTML Validator is not handling the script properly. Because the value of the "value" attribute is PHP, it should not perform that check. The value of 5 is coming from the way CSS HTML Validator internally handles PHP like that.

This updated config file should fix the problem:
https://www.htmlvalidator.com/downloads ... 180cfg.zip

Please see the "readme" file in the above ZIP file for installation instructions.
Image
Albert Wiersch

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

Re: Form input maxlength error

Post by Lou » Thu Sep 06, 2018 3:08 pm

Thank you Albert
Lou
Say what you will about Sisyphus. He always has work.

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3363
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Form input maxlength error

Post by Albert Wiersch » Fri Sep 07, 2018 9:06 am

Lou wrote:
Thu Sep 06, 2018 3:08 pm
Thank you Albert
You're welcome! As usual, please let me know if you encounter any other issues.
Image
Albert Wiersch

Post Reply