JSF <f:validateLength> Tag

It is used to check whether the length of a component's value is within a certain range or not. The value must be a java.lang.String.

# Tag Attributes

Attribute Description
minimum It is used to set minimum length for the component.
maximum It is used to set maximum length for the component.

// index.xhtml

<h:form id="user-form">
<h:outputLabel for="name">User Name</h:outputLabel><br/>
<h:inputText id="user-name" value="#{user.name}">
<f:validateLength  minimum="5"  maximum="10"/>
<h:commandButton value="OK" action="response.xhtml"></h:commandButton>

// User.java

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.validation.constraints.NotNull;
public class User{
String name;
public String getName() {
return name;
public void setName(String name) {
this.name = name;


JSF F validatelength tag 1

JSF F validatelength tag 2