Page 1 of 1

Form input maxlength error

Posted: Thu Sep 06, 2018 12:35 pm
by Lou

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)

Re: Form input maxlength error

Posted: Thu Sep 06, 2018 2:05 pm
by Albert Wiersch
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.

Re: Form input maxlength error

Posted: Thu Sep 06, 2018 3:08 pm
by Lou
Thank you Albert

Re: Form input maxlength error

Posted: Fri Sep 07, 2018 9:06 am
by Albert Wiersch
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.