Search code examples
htmljsfhtml-inputpassthrough-attributes

How do I set the min attribute for <input type="date"> via h:inputText?


I have the following HTML calendar:

<h:inputText t:type="date" value="#{data.dueDate}">
    <f:convertDateTime pattern="yyyy-MM-dd"/>
</h:inputText>

How can I add the min attribute for this?

t refers to xmlns:t="http://xmlns.jcp.org/jsf/passthrough"


Solution

  • With input type date you can use min and max attributes. You can set the min attribute the same way you used passthrough to set the type="date" attribute. So, for example:

    <h:inputText t:type="date" t:min="2016-12-31" value="#{data.dueDate}">
      <f:convertDateTime pattern="yyyy-MM-dd"/>
    </h:inputText>
    

    See also: