Possible False Warning Message

For technical support for all editions of CSS HTML Validator. Includes bug reports.
Post Reply
kennedyrt
Rank II - Novice
Rank II - Novice
Posts: 20
Joined: Fri Nov 09, 2007 9:57 pm
Location: Kent, Washington

Possible False Warning Message

Post by kennedyrt » Thu Oct 06, 2016 4:25 pm

CSE HTML Validator Professional v16.0403 flags as a warning the Javascript "and" (&&) condition in the following:

Code: Select all

<p>Primary Local Administrator: <input name="adminID" type="text" maxlength="10"  id="adminID"  size="8"  onblur="if( !_CF_hasValue(this, 'TEXT', false) && !_CF_checkrange(this.value,1.0,9.999999999E9, true) || !_CF_checkinteger(this.value, true) ){ _CF_onErrorAlert(new Array('BEMSID must be in the range 1-9999999999')); }" /></p>
[64] "&" is an invalid character reference in the value for the "onblur" attribute. This may be because the '&' character was not escaped as "&". To use a literal ampersand it must be encoded as "&" (even in URLs) because '&' is an escape character in HTML/XHTML.

Is this the correct behavior?

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

Re: Possible False Warning Message

Post by Albert Wiersch » Thu Oct 06, 2016 4:54 pm

Hello,

Yes, that is the correct behavior. Because that JavaScript is in an HTML attribute value, the '&' characters should be specified using the '&' character reference.

Of course most browsers still work with the 'raw' ampersand characters because if a valid character reference isn't provided, the browser just treats it as a '&' character.
Image
Albert Wiersch

Post Reply