Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are you allowed to have an input without a value?

Tags:

html

forms

input

Is the following allowed?

<input type="hidden" name="field" />
like image 632
Darryl Hein Avatar asked Mar 29 '09 23:03

Darryl Hein


2 Answers

It is fine in hidden fields. It is only required in checkbox and radio inputs. It can never be specified with a file input. See http://www.w3schools.com/TAGS/att_input_value.asp

like image 129
carl Avatar answered Sep 28 '22 01:09

carl


XHTML 1.1 schema says that value is not mandatory:

 <xs:attributeGroup name="xhtml.input.attlist">
    <xs:attributeGroup ref="xhtml.Common.attrib"/>
    <xs:attribute name="type" type="xhtml.InputType.class" default="text"/>    
    <xs:attribute name="name" type="xh11d:CDATA"/>
    <xs:attribute name="value" type="xh11d:CDATA"/>
    <xs:attribute name="checked">
      <xs:simpleType>
        <xs:restriction base="xs:NMTOKEN">
          <xs:enumeration value="checked"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="size" type="xh11d:Number"/>
    <xs:attribute name="maxlength" type="xh11d:Number"/>
    <xs:attribute name="src" type="xh11d:URI"/>
    <xs:attribute name="tabindex" type="xh11d:Number"/>    
    <xs:attribute name="accesskey" type="xh11d:Character"/>
  </xs:attributeGroup>
like image 22
Assaf Lavie Avatar answered Sep 28 '22 02:09

Assaf Lavie