A List Apart: Articles: Validating a Custom DTD
A List Apart: Articles: Validating a Custom DTD
Don't use “custom DTDs”!
Specifying the attributes
#IMPLIED means optional, #REQUIRED means required,
common types are NUMBER, CDATA
<!ATTLIST TEXTAREA
name CDATA #IMPLIED
rows NUMBER #REQUIRED
....
>
add maxlength property to texarea
<!ATTLIST textarea maxlength CDATA #IMPLIED>
add 'required' property to textarea, which value may be 'true' or false
<!ATTLIST textarea required (true|false) #IMPLIED>
<!ATTLIST INPUT
checked (checked) #IMPLIED -- for radio buttons and check boxes --
disabled (disabled) #IMPLIED -- unavailable in this context --
readonly (readonly) #IMPLIED -- for text and passwd --
>
Placing the attributes
The very best place to put them would be as the internal subset directly in your document:
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
[
<!ATTLIST textarea maxlength CDATA #IMPLIED>
<!ATTLIST textarea required (true|false) #IMPLIED>
<!ATTLIST input required (true|false) #IMPLIED>
<!ATTLIST select required (true|false) #IMPLIED>
]>
Unfortunately, when you display the file in a browser, the ]> shows up on the screen. There’s no way around this bug, so this approach is right out.
沒有留言:
張貼留言